How AJAX works?

Before using AJAX it is important to know how it’s going to work on real time applications. SO first of all of you have to know that AJAX is not a single technology it is a group of technologies like HTML, CSS, JavaScript and DOM etc. In AJAX HTML and CSS is used to do any type of interface related work like creating HTML web pages with different styles to make a web page more dynamic and attractive. The DOM is an entrance with JavaScript to display the web pages dynamically and it allows user to interact with the application and finally the JavaScript and XMLHttpRequest object gives you a way for interchange or exchange the data asynchronously between server and browser without reloading the whole page.

Here is an image which will help you to understand how AJAX really work and it also compare that how traditional web site is differ than AJAX based web site.

ajax

Now we are going to understand “how AJAX works?” step by step:

  • When you are accessing any web site you enter URL of that web site in address bar and then you hit the enter button. After that the web sites home page is loaded in the browser.
  • After loading that web page you perform some actions or trigger some events like you click over a link or you fill a form and submit it by clicking on button.
  • AJAX is call when the event fires and sends the request to the server with the help of XML.
  • Then server catches the input from AJAX or http request and precedes the request and if it is required then it also prepare the response data.
  • After that server sends data back to the original web site that made the request.
  • And finally a JavaScript function called a callback function, gets the data from server and updates the web page behind the scene.

Leave a Reply

Your email address will not be published. Required fields are marked *