Call multiple GlideAjax in a single client script

BALAJI K R
Tera Expert

Is it possible Call  two or more GlideAjax in a single client script

1 ACCEPTED SOLUTION

Samaksh Wani
Giga Sage
Giga Sage

Hello @BALAJI K R 

 

Check below pattern of script for reference of your requirement.

 

 

function onLoad()
{
var ajax = new GlideAjax('MyDateTimeAjax');
ajax.addParam('sysparm_name', 'firstfunction');
ajax.getXML(ajaxResponse);
function ajaxResponse(serverResponse) {
var answer = serverResponse.responseXML.documentElement.getAttribute("answer");
alert("s1"+answer);
}
var ajax1 = new GlideAjax('MyDateTimeAjax');
ajax1.addParam('sysparm_name', 'secondfunction');
ajax1.getXML(ajaxResponse1);
function ajaxResponse1(serverResponse) {
var answer1 = serverResponse.responseXML.documentElement.getAttribute("answer");
alert("s2"+answer1);
}
}

 

 

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Samaksh

View solution in original post

3 REPLIES 3

Samaksh Wani
Giga Sage
Giga Sage

Hello @BALAJI K R 

 

Check below pattern of script for reference of your requirement.

 

 

function onLoad()
{
var ajax = new GlideAjax('MyDateTimeAjax');
ajax.addParam('sysparm_name', 'firstfunction');
ajax.getXML(ajaxResponse);
function ajaxResponse(serverResponse) {
var answer = serverResponse.responseXML.documentElement.getAttribute("answer");
alert("s1"+answer);
}
var ajax1 = new GlideAjax('MyDateTimeAjax');
ajax1.addParam('sysparm_name', 'secondfunction');
ajax1.getXML(ajaxResponse1);
function ajaxResponse1(serverResponse) {
var answer1 = serverResponse.responseXML.documentElement.getAttribute("answer");
alert("s2"+answer1);
}
}

 

 

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Samaksh

Sagar Pagar
Tera Patron

Hi @BALAJI K R,

 

Yes. Possible to use the multiple GlideAjax call in a same client scripts as per the requirements.

 

Note: If there is complex and time taking GlideAjax call, may be you can keep in separate client scripts.

 

If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.


Thanks,


Sagar Pagar

The world works with ServiceNow

manjusha_
Kilo Sage

@BALAJI K R 

 

Calling multiple glideajax is a time consuming activity, user has to wait for a long time 

Explain your use case in details so i can help you.

 

Thanks,

Manjusha Bangale