Skip to content
IT Canvass
Development · Lesson

GlideAjax (async)

Quick answer

GlideAjax is how a client script asks the server a question, 'what is this user's manager?', 'is this value unique?', and gets an answer asynchronously, without blocking the browser. It is the correct, performant alternative to synchronous lookups that freeze the form.

Key takeaways

  • Two halves
  • Why it matters
  • Try it Yourself

GlideAjax is how a client script asks the server a question, 'what is this user's manager?', 'is this value unique?', and gets an answer asynchronously, without blocking the browser. It is the correct, performant alternative to synchronous lookups that freeze the form.

Two halves

You write a client-callable Script Include (extending AbstractAjaxProcessor) and call it from the client with GlideAjax.

// Script Include (server): client callable = true var GetManager = Class.create(); GetManager.prototype = Object.extendsObject(AbstractAjaxProcessor, { managerName: function() { var u = new GlideRecord('sys_user'); u.get(this.getParameter('sysparm_user')); return u.manager.getDisplayValue(); }, type: 'GetManager' });
// Client script var ga = new GlideAjax('GetManager'); ga.addParam('sysparm_name', 'managerName'); ga.addParam('sysparm_user', g_form.getValue('caller_id')); ga.getXMLAnswer(function(answer) { g_form.setValue('u_manager', answer); });
Always use the async callback. Prefer getXMLAnswer (or getXML) with a callback. The synchronous variants (getXMLWait) block the browser and are strongly discouraged, they are the classic cause of 'the form hangs' complaints.

Why it matters

GlideAjax keeps forms responsive while still reaching real server data and logic. Combined with a well-factored Script Include, the same server method serves client scripts, business rules and widgets.

Want to learn this properly?

Our live, instructor-led ServiceNow Training covers this hands-on, with real projects and a certification path.

Check your understanding

  1. GlideAjax lets a client script...

    • A. Call server logic asynchronously
    • B. Edit the database directly
    • C. Restart the instance
    Show answer

    A. Call server logic asynchronously

    It calls a server Script Include without a page reload.

  2. The server Script Include must extend...

    • A. AbstractAjaxProcessor
    • B. GlideRecord
    • C. GlideForm
    Show answer

    A. AbstractAjaxProcessor

    Client-callable Script Includes extend AbstractAjaxProcessor.

  3. You should retrieve the answer with...

    • A. An async callback (getXMLAnswer)
    • B. getXMLWait (sync)
    • C. alert()
    Show answer

    A. An async callback (getXMLAnswer)

    Async callbacks keep the form responsive; sync blocks the browser.

Frequently asked questions

What does the term GlideAjax (async client-server) refer to in ServiceNow?

GlideAjax is how a client script asks the server a question, 'what is this user's manager?', 'is this value unique?', and gets an answer asynchronously, without blocking the browser. It is the correct, performant alternative to synchronous lookups that freeze the form.

What else is worth knowing about GlideAjax (async client-server)?

GlideAjax keeps forms responsive while still reaching real server data and logic.
CallWhatsAppEnquire