dcsimg
IE is not detecting AJAX
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   anand_ramu
Posted On:   Monday, February 26, 2007 05:16 AM

Hi all,
I am using IE 6.O. as a part of my requirement i am using AJAX but it is not detected by the IE 6.0, but it is perfectly working in opera broswer.

kindly throw some lights how to make the IE to detect AJAX

Anticipating your positive reply

Anand

Re: IE is not detecting AJAX

Posted By:   Anonymous  
Posted On:   Sunday, March 4, 2007 09:52 AM

Hi Anand,

You can use this reusable function to create request object for almost all browsers..


/***********************************************************************************
* Function Name : createRequestObject
* Purpose : This function is used to create the request object that will be
* used to send AJAX calls to the server.
*
**********************************************************************************/
var request;
function createRequestObject()
{
try
{
// Trying to create an XMLHttpRequest
request = new XMLHttpRequest();
}
catch( trymicrosoft )
{
try
{
// Trying to create a request object for IE
request = new ActiveXObject("Msxml.XMLHTTP");
}
catch ( othermicrosoft )
{
try
{
// Trying to create a request object for higher versios of IE
request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch ( failed )
{
// The current browser does not support AJAX
request = null;
}
}
}

if( request === null )
{
alert( " Error creating a request object on this browser." );
}
}

Note that request is a variable that is declared.

Re: IE is not detecting AJAX

Posted By:   Anonymous  
Posted On:   Monday, February 26, 2007 05:29 AM

Hi Ananad,

If you are using the XmlHttpRequest Object to create a request for Ajax it will work in Opera/Mozilla/FireFox and other browssers except in IE.If you want to workwith the IE as well you need to use the ActiveXObject.See the below example..

if (window.XMLHttpRequest) {

req = new XMLHttpRequest();

} else if (window.ActiveXObject) {

req = new ActiveXObject("Microsoft.XMLHTTP");

}

if browser is other than IE then the if statement will be executes if it is a IE browser then else will be executed and the req will be created using the ActiveXObject.Which works fine with the IE browser..

Regards,

Krishna Rajendra A.
About | Sitemap | Contact