The CreatorCon Call for Content is officially open! Get started here.

How to call script include from UI Page client script section ?

fisfreak
Kilo Contributor

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

 

20 REPLIES 20

Gaurav Bajaj
Mega Sage

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);
	
}

find_real_file.png

Thanks

Gaurav

Hi Gaurav,

Please find my code snippet below, I have tried exactly same as yours, but no luck

find_real_file.png

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.

is ControlVirtualMachinesAjax client callable and active? Also, check your browser console for any errors.

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 ??