Welcome to WebmasterWorld Guest from 54.159.214.27

Forum Moderators: open

Object does not support error in IE7

object does not support error in IE7 , ajax

   
9:44 am on Jan 19, 2007 (gmt 0)

5+ Year Member



This is the code i am using for ajax call... the code is working fine with all the lower version browsers 5.5 , 6 and giving object doesnot support error only in Internet explorer 7.. why? any one help me?...

The code follows
// JScript source code
<script>
function getXMLObj()
{
if (window.XMLHttpRequest)
{ // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType)
{
http_request.overrideMimeType('text/xml');
return(http_request);// See note below about this line
}
}
else if (window.ActiveXObject)
{ // IE
try
{
http_request = new ActiveXObject("Msxml2.XMLHTTP");
return(http_request);
}
catch (e)
{
try
{
http_request = new ActiveXObject("Microsoft.XMLHTTP");
return(http_request);
}
catch (e)
{alert("Your Browser settings not suitable");
}
}

}
}

var XMLObj;
function getCons()
{
XMLObj=new getXMLObj();
url="test.aspx";
XMLObj.onreadystatechange=loadItems;
XMLObj.open('GET',url,true);
XMLObj.send(null);

}
function loadItems()
{
if (XMLObj.readyState==4)
{

var obj=document.getElementById("myDIV");
obj.innerHTML=XMLObj.responseText;

}

}
</script>

12:53 am on Jan 20, 2007 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



I am having similar problem, this link [blogs.msdn.com...] is relevent but seems to indicate your code is ok. Can you narrow problem to a particular line? My problem is getting responseXml, responseText is Ok and getResponseHeader("Content-Type") = text/xml and xml looks valid.
10:52 pm on Jan 22, 2007 (gmt 0)

5+ Year Member



Because IE7 does support window.XMLHttpRequest, but does not support
.overrideMimeType, so you are returning null from the function.
11:19 pm on Jan 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



overrideMimeType shouldn't come into play if it's not available, according to the script. Maybe your IE7 is having trouble getting the appropriate ActiveX object version? Here's what I use with no IE7 trouble:

var msxmlhttp = new Array(
'Msxml2.XMLHTTP.5.0',
'Msxml2.XMLHTTP.4.0',
'Msxml2.XMLHTTP.3.0',
'Msxml2.XMLHTTP',
'Microsoft.XMLHTTP');
for (i=0;i<msxmlhttp.length;i++) {
try {
thisConn = new ActiveXObject(msxmlhttp[i]);
} catch (e) {
thisConn = null;
}
}
if(!thisConn && typeof XMLHttpRequest!= "undefined") {
thisConn = new XMLHttpRequest();
}
if (!thisConn) {
thisConn = false;
}

Hope it's helpful.

4:32 pm on Jan 23, 2007 (gmt 0)

5+ Year Member



function getXMLObj() {
if (window.XMLHttpRequest){ // Mozilla, Safari,... &&IE7!
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType){ //Not in IE7
http_request.overrideMimeType('text/xml');
return(http_request);// See note below about this line
}
}
else if (window.ActiveXObject){

The above code finds window.XMLHttpRequest for IE,
and so it does not run the else to get an ActiveX object.

But there is no return value for a browser that does support
XMLHttpRequest but does not support overrideMimeType,
as in IE7.

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month