Examples of synchronous GlideAjax

Use synchronous when your script cannot continue without the GlideAjax response. This stops the session until the response is received.

If your use case demands that no further processing can occur until the GlideAjax response has been received, you can use getXMLWait(). However, because this will slow down your code and lock the user session until the response is received, it is generally recommended that you use getXML() with a callback function.

Note: Do not use AJAXEvaluateSynchronously.
Note: The getXMLWait() method is not available in scoped applications.

This code results in a client-side alert that displays The Server Says Hello Bob!.

The client code.
var ga = new GlideAjax('HelloWorld') ;
ga.addParam('sysparm_name','helloWorld');
ga.addParam('sysparm_user_name',"Bob");
ga.getXMLWait(); 
alert(ga.getAnswer());
The server-side script include code.
var HelloWorld = Class.create();
HelloWorld.prototype = Object.extendsObject(AbstractAjaxProcessor, {
helloWorld: function() { return "The Server Says Hello " + this.getParameter('sysparm_user_name') + "!"; } } );