
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2015 02:59 PM
Hello all,
Is there a way to pass value to the callback function when we use GlideAjax.
function onChange (){
var temp = '123';
var x = new GlideAjax ('ABC');
x.addParam ('sysparm_name','123');
x.getXML(callBack,temp);
}
function callBack (response,temp){
alert(temp);
}
Here i want to pass the value of variable temp to the callback function without declaring it as a global variable.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2015 03:39 PM
Hello Ravio,
You can do it with a closure:
function onChange(){
var temp = '123';
var x = new GlideAjax('ABC');
x.addParam ('sysparm_name', '123');
x.getXML( function (response) { callback (response, temp); });
}
function callBack (response, temp){
alert(temp);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2015 03:02 PM
not really as familiar with ajax as I should be but have y ou tried this...
in the function put in return temp
now when you call it.. call it like this...
alert(function callBack (response,temp));

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2015 11:08 AM
Hello Doug,
If possible, can you show it in the form of code on exactly how this will work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2015 03:39 PM
Hello Ravio,
You can do it with a closure:
function onChange(){
var temp = '123';
var x = new GlideAjax('ABC');
x.addParam ('sysparm_name', '123');
x.getXML( function (response) { callback (response, temp); });
}
function callBack (response, temp){
alert(temp);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2015 10:47 AM
Thanks Edwin. This worked!