AJAX is a combination of:
- XMLHttpRequest object is a built-in browser and is used to request data from a server.
How does AJAX work?
AJAX allows web pages to be updated asynchronously by sending and receiving the data in the background. It allows updating parts of a web page, without having to reload the whole page.
By not sending all form data to the server, network utilization is minimized and quicker operations occur on servers. The data being sent to and from the server is minimal so servers do not have to process other data that is not required in that particular operation. By sending only the necessary data, limited processing happens on the server-side. This makes applications to be more responsive, faster, and more user-friendly.
- An event occurs on a web page
- The XMLHttpRequest object sends a request to a web server
- The server receives and processes the request
- The server sends the response back to the web page after processing the request
Conventional web applications exchange information with the server using synchronous requests. It means the user has to fill in a form, submit the form, and get directed to a new page after the request is processed from the server.
Popular uses in web-development
- Data validation in the forms, user logins verification from the server
- changes the values in a drop-down list-box based on inputs by the users. E.g. When a user selects a country, the list of states box will repopulate automatically
- Autocomplete text boxes
- To submit reviews and ratings
- Instant messaging systems
- in lightboxes, lightboxes are pop-ups within a web page. they increase the interactivity of the sites, do not annoy users with unnecessary pop-up screens,s and are not blocked by the pop-up blockers.