Skip to content
Andy Theuninck edited this page Feb 13, 2015 · 1 revision

Asynchronous JavaScript and XML (AJAX) is a method of requesting and transmitting data in the background of a web page. It's the backbone of most modern(ish) web "apps". Wikipedia.

JavaScript on the client page sends a request to the webserver. It may be information that the webserver should save; it may be a request to get additional information back from the webserver; it may be both. When the webserver sends a response, a callback JavaScript function runs on the client page. That callback can do just about anything, but most importantly it can interact with the browser document object model (DOM) and update the page the user is looking at.

The main feature here is the client's browser never left the page. Reloading the whole page or loading a different page may introduce a noticeable delay while the screen redraws. In the specific case of POS, keystrokes may be missed during the page load. A cashier working quickly will find dropped keystrokes extremely frustrating.

So why isn't everything an AJAX call? JavaScript engines tend to crash hard. If an error occurs, all JavaScript processing might stop until the next page load. Having some actions reload or change the page provides a fix if the system appears "stuck". If the page DOM changes over and over in a variety of ways it can also become difficult to keep track of what state it's in. Resetting the page periodically or using a different page if the DOM differs dramatically can result in easier code to follow.

Clone this wiki locally