Scripting-Client Script

Nandhinisri
Tera Contributor

Hi,

 

Can anyone explain me what does the below line return?

function mycallback(response){

 var variable_name = response.responseXML.documentElement.getAttribute("variable_name");

////////.......... some piece of code

}

 

Thanks in advance

 

4 REPLIES 4

Ankur Bawiskar
Tera Patron

@Nandhinisri 

it's a syntax to get the value from AJAX function

Nowadays we use getXMLAnswer() syntax to get the value from ajax

var ga = new GlideAjax('checkRecords');
    ga.addParam('sysparm_name', "checkRecordPresent");
    ga.addParam('sysparm_userID', g_form.getValue('user_id_variable')); // give here user_id variable name
    ga.getXMLAnswer(function(answer){

aler(answer); // this gives you the response
 });

If my response helped please mark it correct and close the thread so that it benefits future readers.

@Nandhinisri 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

GopikaP
Mega Sage

Hi @Nandhinisri ,This is the callback function executed after the GlideAjax call. It retrieves whatever value is returned by the client-callable script include. 

Please see : GlideAjax Example Cheat Sheet - ServiceNow Community

If you can provide screenshots of the script include and client-side script, I can give a more precise answer.

The link provided is useful. Thanks