Sunday, May 23, 2010

ajax object xmlHttpRequest and xmlHttpResponse

var xmlHttp = createXmlHttpRequestObject();

function createXmlHttpRequestObject()
{
var xmlHttp;
// if running Internet Explorer
if(window.ActiveXObject)
{
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlHttp = false;
}
}
}
// if running Mozilla or other browsers
else
{
if(!xmlHttp && typeof ActiveXObject == "undefined")
{
try {
xmlHttp = new XMLHttpRequest();
} catch (e) {
xmlHttp = false;
}
}
}
// return the created object or display an error message
if (!xmlHttp)
{
alert("Error creating the XMLHttpRequest object.");
}
else
{
return xmlHttp;
}
}

in reference to: Google (view on Google Sidewiki)

No comments:

Post a Comment