JSON Client-Side Script

var incGA = new GlideAjax('CallerIncidents');
incGA.addParam('sysparm_name','getCallersIncs');
incGA.addParam('sysparm_callerID',g_form.getValue('caller_id'));
incGA.getXMLAnswer(CallerIncidentsParse);

function CallerIncidentsParse(response) {
    var myObj = JSON.parse(response);
    g_form.addInfoMessage('User has raised the following incidents:');

    for (var i=0; i< myObj.lenght; i++) {
        g_form.addInfoMessage(myObj[i].number + ': ' + myObj[i].shortDesc);
    }
}

The client-side code shown here would be wrapped in a function (onLoad(), onSubmit(), or onChange()) depending on the type of client-side script.

The JSON.parse() method creates an object from a JSON formatted string.

results matching ""

    No results matching ""