getXML() vs getXMLAnswer()? which is the best to use?

mallikharjunasw
Tera Contributor

getXML() vs getXMLAnswer()? which is the best to use?

1 ACCEPTED SOLUTION

Chris M3
Tera Guru

 

getXMLAnswer() saves you a line of code every time you use it.  That is it.  There shouldn't be any noticeable difference in speed, though this method is probably guaranteed to be slightly slower as it runs at least one more line of code each time.  So ease of use vs minuscule difference in speed. 

with getXMLAnswer() uou no longer need this line of code.

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

View solution in original post

10 REPLIES 10

Kunal Varkhede
Tera Guru

Hi,

 

If we compare both then getXML() is best option for performance wise. Beacause it is not wait for response. 

 

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();

 

Hit Helpful or Correct on the impact of response
 
Regards,
Kunal Varkhede
 

Sangeeta Choudh
Giga Expert

Hi mallikharjunaswamyvutla,

getXML(Function callback)

Sends the server a request to execute the method and parameters associated with this GlideAjax object.

The server processes the request asynchronously and -- when ready -- returns the results via the function specified as the callback_function.

Parameter(s):
NameTypeDescription
callbackFunction

The name of the callback function to process the results returned by the server.

 

 

 

 

getXMLAnswer(Function callback)

Call the processor asynchronously and get the answer element of the response in XML format.

Parameter(s):
NameTypeDescription
callbackFunction

The callback function. The function receives the answer element of the response in XML format as an argument.

 

THANKS !!

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

It all depends on the scenario you are into

1) getXMLWait() is used during onsubmit validation when you are waiting for the script include response so that you can abort the form save

2) getXML() is used when you don't want to wait for the script include function and asynchronously execute the code

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Inactive_Us2547
Mega Contributor

Hi Ankur,

its other way around..

Thanks Amit.

Updated the comment.

Regards

 

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader