Welcome to WebmasterWorld Guest from 54.226.34.209

Forum Moderators: open

Message Too Old, No Replies

Object does not support error in IE7

object does not support error in IE7 , ajax

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

New User

10+ Year Member

joined:May 24, 2006
posts:13
votes: 0


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)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Nov 3, 2005
posts:1585
votes: 0


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)

New User

10+ Year Member

joined:Feb 22, 2006
posts:24
votes: 0


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)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 20, 2004
posts:1477
votes: 0


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)

New User

10+ Year Member

joined:Feb 22, 2006
posts:24
votes: 0


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.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members