Glide Ajax 101-Beginner Level ( Inspired by Shawn Dowler)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2024 12:27 PM - edited 11-21-2024 08:33 AM
Overview
Overview
GlideAjax can be tricky to use due to its client-server structure. To simplify its implementation, I created this color-coded example to ensure all details are covered when setting up a new call. This guide includes an image, text, and a downloadable Word document for your convenience.
Important: Ensure the Client callable option is checked in your Script Include for GlideAjax to work.
Color Codes Explanation
🟡 Yellow:
The name of the class in the Script Include, often identical to the Script Include's name.
🟣 Magenta:
The name of the function in the Script Include. You can have multiple functions within a single Script Include, each handling different parameters and processes.
🟢 Green:
Parameters passed via the URL during the AJAX call. Typically, these are used to retrieve data using a GlideRecord query.
🔴Red:
The callback function that waits for a server response. This function, referenced by getXML(), handles operations dependent on the server response. Code that doesn’t need to wait for a response can be placed directly after the getXML() call.
🔵Cyan:
Data returned from the server, encapsulated in an object. These values can be utilized for various tasks, such as setting field values in a form.
Client-Side Code (Client Script)
Server-Side Code (Script Include):
var asu_GetLocationData = Class.create();
asu_GetLocationData.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getCampus: function () {
var buildingId = this.getParameter('sysparm_buildingid');
var loc = new GlideRecord('cmn_location');
if (loc.get(buildingId)) {
var campus = new GlideRecord('cmn_location');
if (campus.get(loc.parent)) {
return JSON.stringify({
"sys_id": campus.getValue("sys_id"),
"name": campus.getValue("name")
});
}
}
return null;
}
});
Thanks
Credits: Shawn Dowler

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 06:46 AM - edited 11-20-2024 06:48 AM
You should give credit to the original article, as yours is using the exact same code (just changing getXMLAnswer to getXML) and color structuring with a few words changed in the color descriptions, instead of passing it off as your own. This makes it confusing for people who are looking for information on their issues.
Original article:
GlideAjax Example Cheat Sheet (UPDATED)