Académique Documents
Professionnel Documents
Culture Documents
e.g.
XMLHttpRequest
If we are using
Firefox, Opera 8.0+, Safari,IE 8
objectname=new XMLHttpRequest();
if we are using
objectname=new
ActiveXObject("Msxml2.XMLHTTP");
objectname=new
ActiveXObject("Microsoft.XMLHTTP");
function functioname()
{
var ob;
try
{
//for IE8
ob=new XmlHttpRequest();
}
catch(e)
{
try
{
//for IE 6.0
ob=new
ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
//for IE 5.0
ob=new
ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{
alert("Your browser
doesnot support Ajax.");
}
}
}
objectname.onreadystatechage=function()
{
//code which will be used for handling
the request
}
The readyState Property
The readyState property holds the status of the server's
response.
Each time the readyState changes, the onreadystatechange
function will be executed.
Here are the possible values for the readyState property:
State Description
0 The request is not initialized
1 The request has been set up
2 The request has been sent
3 The request is in process
4 The request is complete
objectname.onreadystatechage=function()
{
if(readyState==4)
{
//code which will be used for
handling the request
}
}
objectname.onreadystatechage=function()
{
if(readyState==4)
{
//code which will be used for
handling the request
..... = objectname.responseText;
}
}
open(method,"filename",true);
The open() function specify ,