Skip to main content

Short note: AJAX

Short answer

AJAX is a technique using JavaScript and XMLHttpRequest to exchange small data with the server asynchronously and update part of the page without reloading. It gives faster, interactive pages and less bandwidth, but needs JavaScript and has debugging, back-button and security concerns.

Write a short note on AJAX.

AJAX (Asynchronous JavaScript and XML) is a web development technique that lets a page exchange small amounts of data with the server in the background and update only part of the page, without reloading it. It was named by Jesse James Garrett (2005).

Technologies used

  • HTML/XHTML and CSS for presentation.
  • DOM to change the page dynamically.
  • JavaScript to control the process.
  • XMLHttpRequest object (or fetch) for the asynchronous request.
  • XML or JSON (or plain text) for data exchange.

Working

  1. A user event (click, typing) fires a JavaScript function.
  2. The function creates an XMLHttpRequest and sends it to the server asynchronously.
  3. The server processes the request (PHP, JSP, CGI) and returns XML/JSON.
  4. A callback function receives the response and updates part of the page using the DOM.
 Browser UI -> JavaScript -> XMLHttpRequest ---> Server
      ^                                            |
      +------ update DOM <---- XML/JSON ----------+

Advantages

  • Faster, interactive pages and a better user experience.
  • Less bandwidth and server load.
  • The user can continue working during the request.

Disadvantages

  • Needs JavaScript enabled; browser back button and bookmarks may not work as expected.
  • Harder to debug; security issues such as XSS if input is not handled.
  • Search engines may not index dynamic content well.

Examples: Google Suggest, Gmail, Google Maps, live form validation.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Internet and Intranet chapter 6 questions →