Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to show Loading form while waiting for response from script include?

inderpal
Kilo Expert

I have created a button on click of which a script include is called. I am using getXMLWait() for response to come from script include. It takes very much time to have the response from script include because of large processing in my script.
So for a while it looks like nothing is happening after clicking that button.
Is there any way i can show loading form or processing meanwhile on the screen?
i have used showLoadingDialog() method before calling my script include but it is not working..

My script is:

function XYZ() {

showLoadingDialog();

  var sub = new GlideAjax("XYZOrder");

  sub.addParam('sysparm_name', "Order");

  sub.getXMLWait();

  var yes = sub.getAnswer();

  hideLoadingDialog();

}

Please Help!!

1 ACCEPTED SOLUTION

I've run into this as well, some browsers don't load it for it processes to quickly; I've found a workaround with using setTimeout()



JavaScript Timing Events



Could try that and see if it assists? (long shot but may work).


View solution in original post

9 REPLIES 9

I've run into this as well, some browsers don't load it for it processes to quickly; I've found a workaround with using setTimeout()



JavaScript Timing Events



Could try that and see if it assists? (long shot but may work).


Thanks Erik Brostrom.


It is working when i am giving delay of 1 sec.


derycklio
Mega Expert

Have you tried using the async getXML method like:



function XYZ() {


  showLoadingDialog();


  var sub = new GlideAjax("XYZOrder");


  sub.addParam('sysparm_name', "Order");


  sub.getXML(function() {


  var yes = sub.getAnswer();


  hideLoadingDialog();


  });


}


Sync or Async showLoadingDialog(); works. I have used in many of my implementation


inderpal
Kilo Expert

Thanks all for your suggestions and help.