Programming Programming Knowledge

What is AJAX?

June 6, 2018

what would happen if Facebook reloads the news feed every time you scroll through the end of news feed?

Not exactly agonizing right, consider how frequently you more likely than not reloaded when you like up to 5 posts.

Introduction of AJAX

This was the condition of the web before the year 2000 when Microsoft presented the Ajax innovation (XMLHttpRequest question) to Internet Explorer which encouraged correspondence to servers without reloading the page. Not long after other enormous organizations like Google and Facebook began fusing it.


Ajax, as you may definitely know, remains for Asynchronous JavaScript and XML. The word Asynchronous is utilized to mean a pack of occasions occurring at unpredictable intervals. You may believe what’s with the XML, XML is a format for passing information from server to customer, it was dropped for HTML and JSON. Yea, nowadays, you can pass crude HTML and JSON around the web utilizing Ajax. JSON is a lighter and straightforward format for passing information around the web.


To write a basic Ajax request, we need to…
  1. Make an instance of the XMLHttpRequest object.
  2. Open the request.
  3. Send the request.
  4. Handle the request.
To clarify the code above. The first line creates an instance of the XMLHttpRequest object. The second line contains an event (onreadystate), this event fires when the request changes. Also, the event handler (handleResponse) handles the event and logs the reaction from the server to the console. The third line opens the request. As the open() method takes three arguments. The first is the action of the request. It could be GET (to retrieve information), POST (to embed information), UPDATE (to refresh information) and DELETE (to erase information). The second is the URL to get the information from. The third is a boolean value that decides whether the request is Asynchronous or not. True value implies an Asynchronous request and False, synchronous (the page will reload), we don’t need that right?. This is all we have to make an Ajax. Very basic right?

You Might Also Like

No Comments

Leave a Reply