- What is Ajax in depth?
Ajax is a set of technologies, supported by a web browser, including these elements :
The XMLHttpRequest object is used to read or send data on the server asynchronously.
The "asynchronous" word, means that the response of the server while be processed when available, without to wait and to freeze the display of the page.
- DOMParser may be used.
- PHP or another scripting language may be used on the server.
- XML and XSLT to process the data if returned in XML form.
- SOAP may be used to dialog with the server.
- How does it works?
Ajax uses a programming model with display and events. These events are user actions, they call functions associated to elements of the web page.
Interactivity is achieved with forms and buttons. DOM allows to link elements of the page with actions and also to extract data from XML files provided by the server.
To get data on the server, XMLHttpRequest provides two methods :
Data furnished by the server will be found in the attributes of the XMLHttpRequest object :
- open: create a connection.
- send: send a request to the server.
Take note that a new XMLHttpRequest object has to be created for each new file to load.
- responseXml for an XML file or
- responseText for a plain text.