Movatterモバイル変換


[0]ホーム

URL:


TheServerSideTheServerSideTechTarget
Definition

AJAX (Asynchronous JavaScript and XML)

Rahul Awati
By
Published:Jan 25, 2022

What is AJAX (Asynchronous JavaScript and XML)?

AJAX (Asynchronous JavaScript and XML) is a technique aimed at creating better and faster interactiveweb apps by combining several programming tools, includingJavaScript, dynamic HTML (DHTML) and Extensible Markup Language (XML).

Based on openstandards, AJAX uses a browser built-in XMLHttpRequest object, JavaScript andHTML Document Object Model (DOM) to exchange data between aweb browser andweb server, and to display this data.

AJAX supports data exchange with a web server behind the scenes and allows webpages to update asynchronously. This makes it possible to update parts of a particular webpage and display the results to a user quickly, without having to wait to reload the entire page.

Understanding Asynchronous JavaScript and XML

AJAX is not a proprietary technology, programming language or a packaged product. Rather, it is a web browser technology and open standard that's independent ofweb server software. It can send and receive information from web servers in various formats, including the following:

  • JavaScript Objection Notation (JSON)
  • XML
  • HTML
  • text files

The AJAX method uses a combination of technologies that allow the content on webpages to update immediately based on a user's action, which may be a click on a page or even a simple mouse movement. Just one or a few parts of the page may be refreshed, instead of reloading or refreshing the entire page. This differentiates AJAX from anHTTP request, during which users must wait for a whole new page to load. AJAX can also access data from external sources even after a webpage has loaded completely.

AJAX uses JavaScript for dynamic content display, XHTML for content and XML to receive server data. In addition, it combines many other programming tools, such as the following:

  • cascading style sheets for presentation;
  • DOM for dynamic content display; and
  • Microsoftobject, XMLHttpRequest to fetch data in the web browser.

XMLHttpRequest is an API that can be used by JavaScript and other web browser scripting languages to move and manipulate web browser data to and from a web server using HTTP. Since AJAX relies on XMLHttpRequest, early applications worked only with Microsoft'sInternet Explorer browser. Today, almost all browsers support AJAX.

The 'Asynchronous' in AJAX

AJAX executes within the JavaScriptframework. Here's how the various AJAX processes work asynchronously:

  • Once the HTML page loads, data is read from a web server.
  • Without the need to reload the webpage, the data can be updated.
  • Data transfer happens to the web server in the background.

All theseasynchronous steps help create responsive HTML web content, as well as faster performance. As they achieve these goals, they help maintain a natural user interaction with webpages. Further, since AJAX is not dependent on web servers, it creates a data-driven environment rather than a page-driven environment. That's why it can execute tasks asynchronously and at any time.

How Asynchronous JavaScript and XML works

To understand the workings of AJAX, it's important to remember that it has two key components: the web browser and the web server.

Also, conventional web applications transmit information to and from the web server usingsynchronous requests, which directs the user to a new page with new information from the server. But with AJAX, once a user hits the submit button (or performs some other action), JavaScript makes a request to the server, interprets the results and asynchronously updates the browser's screen.

Here's how the process works:

  1. Some event happens on a webpage. For instance, the page loads, or a user clicks on a particular button.
  2. JavaScript creates an XMLHttpRequest object.
  3. This object sends a request to the corresponding web server.
  4. The server processes the request and sends a response back to the browser.
  5. JavaScript reads the response.
  6. JavaScript performs the proper action, depending on the triggering event.
AJAX in a nutshell, Asynchronous JavaScript and XML
AJAX technologies, components, data formats, steps and applications.

AJAX applications and AJAX engine

AJAX applications don't require the installation of aplugin but work directly with a web browser. These applications usually use XML to transport data. However, they may also transport data asplaintext or JSON text (see the Understanding AJAX section).

AJAX applications use an engine that acts as an intermediary between a user's browser and the server from which it is requesting information. Thus, instead of loading a traditional webpage, the browser loads the engine, which then displays the page to the user. The engine continues to run in the background, using JavaScript to communicate with the browser.

Any input from the user, such as clicking anywhere on the page, sends a JavaScript call to the engine, which responds instantly in most cases. If the engine requires additional data, it requests it from the server, usually using XML, while simultaneously updating the page.

Benefits of Asynchronous JavaScript and XML

Some key advantages of AJAX are as follows:

  • AJAX is based on widely accepted open standards.
  • It enhances the interactivity of webpages.
  • It is highly efficient and fast for responsive web applications in e-commerce and other online platforms.
  • It is a viableRich Internet Application technology and is fairly synonymous withWeb 2.0.
  • AJAX supports intuitive user interactions.
  • It allows content to be updated based on a specific user action, a time interval or some application-specific logic.
  • Many open source toolkits and libraries are available to provide cross-browser support for AJAX-based interactions.
AJAX benefits and drawbacks, Asynchronous JavaScript and XML
Advantages and disadvantages of AJAX.

Disadvantages of AJAX

One drawback of AJAX-based applications is that they require increased communication between web browsers and web servers. This may result in application degradation due to the following:

  • too many web server connections;
  • too manypackets traversing the network; and
  • connection limitations implemented by browsers.

In addition, some browsers may not be compatible with AJAX -- although this is rare. Finally, AJAX requires JavaScript, which can be difficult to debug and maintain.

Applications of AJAX

Google Maps is one well-known application of AJAX. The interface allows users to change views and manipulate the map inReal Time.

AJAX can also be used to create the following:

  • RSS readers
  • desktop tutorials
  • web-basedchat applications
  • calendar applications
  • ratingwidgets
  • contact and login forms
  • charting components

See why collaboration is key to asecure web application architecture and how to apply web application reconnaissance fundamentals toimprove offensive and defensive hacking skills.

Continue Reading About AJAX (Asynchronous JavaScript and XML)

Related Terms

What are beans in Java and Spring?
In 1996, Sun Microsystems introduced its JavaBeans application programming interface for writing a Java component. Continuing ... See complete definition
What is imperative programming?
Imperative programming is a software development paradigm where every step is implicitly coded to solve a problem. See complete definition
What is the DRY principle?
The DRY (don't repeat yourself) principle, introduced by Andrew Hunt and David Thomas in 'The Pragmatic Programmer,' promotes the... See complete definition

Dig Deeper on Core Java APIs and programming techniques

Sponsored News
Vendor Resources
SearchAppArchitecture
SearchSoftwareQuality
SearchCloudComputing
SearchSecurity
SearchAWS
Close

[8]ページ先頭

©2009-2025 Movatter.jp