How to call script include from UI Page client script section ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2018 02:50 AM
Hello,
I need to make a call to script include from UI Page, when i try to invoke a function from client script of UI Page, it is not returning me anything, where as same thing works from catalog client script. please find the code snippet below.
$(document).ready(function() {
var ga = new GlideAjax("ControlVirtualMachinesAjax");
ga.addParam("sysparm_name", "getVMSInRG");
ga.getXML(ajaxResponse);
function ajaxResponse(serverResponse) {
alert("ServerResponse: " + serverResponse);
}
});
Same code works perfect from catalog client script but not from client script of UI Page. In the above code , control never comes inside ajaxResponse method.
Thanks,
Krishna P
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2018 03:09 AM
Hi,
There is no need to call $document.ready function as all the client script gets executed on load in UI page.
I have tried below one and it worked for me.
Also, if you really want to use $document functions, you will have to add the JS lib explicitly in the UI page and then use no conflict so that it doesn't mess up with default jquery of the system.
var ga = new GlideAjax("TestUIPage");
ga.addParam("sysparm_name", "getMsg");
var response=ga.getXMLAnswer(callbackMethod);
function callbackMethod(response) {
alert("response: " + response);
}
Thanks
Gaurav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2018 03:46 AM
Hi Gaurav,
Please find my code snippet below, I have tried exactly same as yours, but no luck
if you see my above code in client script, it is exactly replica of yours, still control is not going inside callbackMethod. ControlVirtualMachinesAjax is a script include and getVMSInRG is a method in it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2018 03:54 AM
is ControlVirtualMachinesAjax client callable and active? Also, check your browser console for any errors.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2018 03:59 AM
I am able to call ControlVirtualMachinesAjax from catalog client script and it works there, but in UI Page i am not able to invoke this from the client script.
BTW, how do you check if it is a client callable or not ??