- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2024 11:05 AM - edited 03-22-2024 11:08 AM
I am using the following script on a UI Action:
function SimpleTest() {
var a = new GlideAjax('FrankNewInclude');
a.addParam('sysparm_name', 'test');
a.getXML(myCallBack);
}
function myCallBack(response) {
alert(response);
var answer = response.responseXML.documentElement.getAttribute("document");
alert(answer);
}
Using the following include:
var FrankNewInclude = Class.create();
FrankNewInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {
initialize: function() {
gs.log('Frank - Initialize');
},
test: function() {
gs.log('Frank - myFunction: ');
return true;
},
type: 'FrankNewInclude'
});
I can see a log message being fired when the object is instantiated but the "test" function is never called.
However, if I remove the "initialize" function then the "test" function works.
Can anyone explain why?
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2024 01:55 PM - edited 03-22-2024 01:56 PM
Your GlideAjax end-point Script Include must not contain an initialize methos.
Or if it does contain one, it must call the base initialize method with the right parameters in the right context:
initialize: function(request, responseXML, gc) {
AbstractAjaxProcessor.prototype.initialize.call(this, request, responseXML, gc);
gs.log('Frank - Initialize');
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2024 01:38 PM
Hi @fcaruso123 ,
Have checked true for client in UI action and in Onclick have you called the function SimpleTest() ?
and also use gs.info to get logs
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2024 01:55 PM - edited 03-22-2024 01:56 PM
Your GlideAjax end-point Script Include must not contain an initialize methos.
Or if it does contain one, it must call the base initialize method with the right parameters in the right context:
initialize: function(request, responseXML, gc) {
AbstractAjaxProcessor.prototype.initialize.call(this, request, responseXML, gc);
gs.log('Frank - Initialize');
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2024 01:58 PM - edited 03-22-2024 01:59 PM
Also, do yourself a favor and use getXMLAnswer (vs. getXML); if you do you can loose all the:
var answer = response.responseXML.documentElement.getAttribute("document");
crap and just need:
function myCallBack(answer) {
alert(answer);
}