AJAX communicates with a web server in a specific way through the use of an object and the web server knows when and how to send and receive data using special properties of the object.
This tutorial focuses on:
- Creating an AJAX object
- AJAX properties
Creating an AJAX object
An AJAX object is created one way for Internet Explorer 5 & 6 and a different way for other browsers. This is just a quick overview of how to create AJAX objects. The next tutorial goes into much more detail with some examples.
Firefox, Safari, Chrome, Opera, Internet Explorer 7+
To create an AJAX object in these browsers, the XMLHttpRequest object is used.
Internet Explorer 5 & 6
To create an AJAX object in these browsers, the ActiveXObject is used.
AJAX properties are special characteristics about an object that dictate how and when a web browser and a web server communicate.
The onreadystatechange property is used to receive information returned by the web server. This property stores the function that will process the response from the web server.
The readyState property is used to store the status of the web server's response. When the readyState changes, the function created by onreadystatechange executes.
The responseText property is used to store the actual information received by the web server.
In the above example, a textbox named 'text' in a form named 'form1' is updated with the value from the responseText property.