GlideAjax call multiple functions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2018 01:19 AM
Hello,
I would like to ask for hint of solution over GlideAjax.
I have UI Action, which works completely as Client side button and calls GlideAjax.
In this Ajax script include is a very time consuming function, from fhich I would like to push some info on states.
Sadly, Ajax is only one-time request-response, so I need to ask for state in some intervals.
The idea is this, but I am pretty sure this will not work, because in this solution, I will rewrite GlideAjax object and I belive, the first response will be lost, same as any other in the interval:
UI Action:
==========
var syncGA = new GlideAjax("Sync_ScriptInclude_Ajax");
syncGA.addParam('sysparm_name', 'timeConsumingOperation');
syncGA.addParam('sysparm_parm1', "...");
syncGA.getXML(parseDoneResponse);
function parseDoneResponse(response) {
//operation was done, say Done to user
clearInterval(check);
}
var check = setInterval(function(){
syncGA.addParam('sysparm_name', 'getState');
syncGA.getXMLWait(parseState);
}, 3000);
function parseState(response) {
//update state message, percentage, whatever
}
Script Include
==============
var Sync_ScriptInclude_Ajax = Class.create();
Sync_ScriptInclude_Ajax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
initialize:function(){
this.result = [];
},
timeConsumingOperation:function(){
//some logic, lets say GlideRecord here with result
while(step-by-step){
this.result.push(step-result);
}
},
getState:function(){
return JSON.stringify(this.result);
},
type: 'Sync_ScriptInclude_Ajax'
});
Is this somehow possible? Or s there any other fancy way, how to do this?
Thanks in advance 🙂
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2018 12:11 AM
Push values to first function only and then pass these to 2nd function through calling statement
function1 : function(){
parm1 = this.getParameter('fucntion_1_Prameter');
parm2 = this.getParameter('fucntion_2_Prameter');
//calling function 2
this.function2(parm2);
//time consuming code here
},
function2 : function(parm){
//use parm 2
return result; //
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2018 02:26 AM
oh ok. I misunderstood. then I agree with Gurpreet.
