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

What is the difference between getXml() and getXmlWait()?

charliee_now
Kilo Explorer

Hi All,

 

In GlideAjax, what is the diff between getXml() and getXmlWait().

 

Thanks

Charliee

4 REPLIES 4

TrevorK
Kilo Sage

Technically speaking, getXMLWait() is a Synchronous call and getXML() is aSynchronous.



What this means in everyday terms:


- getXMLWait() is used when you want to halt processing until the results are returned. This will halt everything and wait for it to finish and return the results


- getXML() is used when you want processing to continue, even if the results have not been returned



What you plan to do will help you decide which will work best. In our instance, we have had situations where we do want to wait for the results before continuing (even though it will take a few seconds). However, for the most part, we use getXML and a callback function for the vast majority of our uses.



I hope that made sense. I am sure someone more knowledgeable can give you a much more indepth answer.



EDIT: I recall in our ServiceNow training that getXML (aSynchronous) is the preferred/recommended method.


msrishilpa
Mega Expert

Hi Charlie,



What trevor had specified is absolutely right.I wanna add one more point on it for better understanding of concept.



When you are trying to retrieve value of the variable.after getting value then only we can proceed next step like comparing it with user input.In such scenarios will use


getXMLWait()



If you are retrieving some data from server and next tasks does not depend on what you are retrieving from server


then will use


getXML();




Please go through this link...


GlideAjax - ServiceNow Wiki


I had a further question about this:



does getXML() require the callback function parameter?


Hi Daniel,



Yes, getXML() needs the callback function.



for Reference :



  1. gr.getXML(setValue);

function setValue(response)


{


var answer = response.responseXML.documentElement.getAttribute("answer");


}



Best Regards.


Priyanka R