10 Practical Applications for AJAX

Tram Ho

AJAX has become more and more popular over the years. AJAX can provide a lot of additional functionality that cannot be done in any other way.

What is AJAX? How it works?

AJAX stands for Asynchronous JavaScript and XML. It is used to allow the client side of an application to communicate with the server side of the application. Before AJAX existed, there was no way for the client side of the web application to communicate directly with the server. Instead, you’ll have to use the page load. With AJAX, the client and server can communicate freely with each other.

Here’s how a regular AJAX script works:

  • Several actions that trigger the event, such as a user clicking a button.
  • The AJAX command fires and sends the request to the server-side script, using XML
  • Server-side script (PHP, ASP or whatever) takes input from JavaScript, can access the database if needed, and process the data.
  • Using XML again, the script sends the data back to the client-side page that made the request
  • A second JavaScript function, called the callback function, fetches and updates the web page

1. Login form

Instead of going to the login page, then navigating back to the page you originally wanted, with AJAX, users can enter their username and password directly into the original page. From there AJAX will send the request to the server to

2. Autocomplete

Google was one of the first big companies to start using AJAX, and Google’s search suggestion engine was one of the first ways they used it and one of the first autocomplete tools created. out. When typing in the Google search bar, it will start using AJAX to get general results from the database on each keystroke. Autocomplete for forms that you can have a lot of input on and if present a dropdown would be too long and cumbersome.

3. Vote and rate

Social bookmarking sites like Digg and Reddit allow users to decide on the main content of a website by voting for the content users like. They use AJAX to handle all polls, so that users can speak up about some of the stories quickly and easily.

4. Updated with user content

One of the things that made Twitter so popular is their simple and easy-to-use interface. When someone creates a “tweet,” it is instantly added to their feed and everything is updated. Recently, Twitter started using AJAX with their ‘trending topic’ pages. Every few seconds, the page lets users know that more tweets have been made on the topic, providing them with updates every second.

5. Form submission & validation

Forms are always complicated to work with, but AJAX can make them a lot better for users. AJAX can be used in a variety of ways, from the autocomplete mentioned above, to confirm and submit. Some websites use AJAX to check if the form meets certain requirements, such as password strength or whether something is a valid email or URL.

6. Chat rooms and instant messaging

Chat rooms and instant messaging can now be completely handled in the browser. There are two main AJAX processes in a chat room or IM app. Take one of them as your ears and one of them as your mouth. Your ‘mouth’ updates the server and lets the server know that you sent the message. “Tai” constantly checks with the server and updates your page with messages sent by whoever you’re chatting with.

7. Flashing user interface

Creating a clean, clean user interface is a very popular use of AJAX. It allows users to get more done on a page. The benefits of this are twofold: First, it makes using the web application faster and easier for the user; Second, it cuts down on the number of requests you have to make to the server, reducing bandwidth and load times. A free file upload service called Drop.io makes good use of this. Google has also really pushed what’s possible with AJAX by creating desktop-like apps like Google Docs and Google Maps.

8. External utilities

When using AJAX, the page that is using JavaScript is not limited to the server it is located on. AJAX can make online calls to any server. Here’s how some of the plugins for Content Management Systems like WordPress and various scripts like Google Adsense work.

9. Light box instead of pop-up window

Popup blockers are very popular these days and for one good reason: popup blockers are annoying. Using light boxes, which are popup visible inside the browser window, the popup blocker cannot stop it and they are not annoying to the user. Some people use them for advertising. They can also be used for something like sign-in or check-in boxes.

Share the news now

Source : Viblo