By Andrew Johnson Dec 29, 2008
In the past web pages were limited in the sense they had to load in their entirety. Changing even a small portion of the content required a new web page to be loaded.
Thankfully modern web sites don't suffer from this restriction because AJAX
object after a web page has loaded.
When you vote on an ITNewb article AJAX is used to send the request to one of our servers which updates the database and responds with a simple XML
document that contains updated statistics. The response is then used to update a few areas on the web page with the new voting statistics without the web page itself ever reloading.
An XMLHttpRequest object isn't limited to the HTTP
protocol as its name implies but also supports other connection types such as FTP
. You can send and receive information in XML, HTML
or plain text via GET, POST, HEAD or any other method supported by your server. This really opens things up and allows us to take interactive web applications to the nth level.
Where it Started
. Mozilla (1.0 / Netscape 7) and Safari (1.2) followed suite by implementing the XMLHttpRequest
class into their browsers which supported the properties of the original Microsoft ActiveX object.
How it works
- HTML / XHTML and CSS for presentation
- Client-server communication via an XMLHttpRequest object
- a callback function is assigned to handle the server response;
- the request is formulated and sent via the request object;
- the server processes the request and responds;
- the callback function catches the response, parses it and updates the DHTML; and
- finally the updated presentation is shown to the user.
Continue with XMLHttpRequest Class ➜