top of page

Moji5 Knowledgebase

Calling Ajax Library from client

To call the Ajax library from external web api, will need to get the endpoint for the library

>>Replace the domain (http://appsmoji.com) and the instance name (M5) with your own application

Will be needing to pass 3 params:

1) AppID = App Guid where the ajax library is created

2) AjaxName = the name for the Ajax Library created in the app

3) strParaList = Data to be passed. (use ~ to concatenate multiple values and pass as single param)

Below is the sample code for calling the Ajax library;

$(document).ready(function () {
    var _splt = '~';
    //process the form
    $('#SubmitData').click(function (event)){
        var appID = 'bee90380-86bc-4f19-8505-7c81c8ed0145';
        var AJAXNAME = 'InsertData';
        var strParaList = $('#Location').val() + _splt + $('#Incidentdate').val() + _splt + $('#EstimationValue').val() + _splt + $('#Allegation').val();
        $.ajax({
            type: 'POST',
            url: 'http://appsmoji.com/m5/LoadAJAX.asmx/ProcessData',
            dataType: 'text',
            data: {
                'appID': appID,
                'search': AJAXName,
                'searchKey': strParaList
            },
            success: function (data) {

                var strData = data.replace('<?xml version="1.0" encoding="utf-8"?>', '');
                strData = strData.replace('<string xmlns="http://tempuri.org/">', '');
                strData = strData.replace('</string>', '');
                var jMyData = JSON.parse(strData);

                if (jMyData.Status == 'Passed') {
                    alert(jMyData.Result);
                } else {
                    alert(jMyData.Result);
                }
            },
            error: function (xhr, status, error) {
                alert('Error :' + error);
                alert(xhr.status + ': ' + xhr.statusText);
            }
        })
    }
})


コメント


bottom of page