Problems with IE returning nothing in responseText

F

furby

I have this little bit of code :
var request = false;
var divid = 0;
var fforie;
try {
request = new XMLHttpRequest();
fforie = "FF";
} catch (trymicrosoft) {
try {
//request = new ActiveXObject("Microsoft.XMLHTTP");
request = new ActiveXObject("Msxml2.XMLHTTP");
fforie = "IE";
} catch (othermicrosoft) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
fforie = "IE";
} catch (failed) {
request = false;
}
}
}
if (!request)
alert("Error initializing XMLHttpRequest!");
function getThreadMessage(parentid) {
divid = parentid;
if(document.getElementById("link" +
divid).innerHTML.indexOf("forum_expand.gif") > 0) {
document.getElementById("loadingdiv"+parentid).style.visibility
= "visible";
if(document.getElementById("srchon").value == "YES") {
var url =
"forum_api.asp?pageaction=GETLEVEL&forumid=<%=request("forumid")
%>&parentid=" + parentid + "&srch=" +
document.getElementById("srchterm").value;
} else {
var url =
"forum_api.asp?pageaction=GETLEVEL&forumid=<%=request("forumid")
%>&parentid=" + parentid;
}
request.open("GET", url, true);
request.onreadystatechange = updatePage;
request.send(null);
} else {
if(divid > 0) {
document.getElementById("link" + divid).innerHTML = '<img
src="images/forum_expand.gif" border="0">';
}
document.getElementById("thread" + divid).innerHTML = "";
}
}
function updatePage() {
if(request.readyState == 4){
if(request.status == 200) {
if(fforie == "FF") {
document.getElementById("thread"+ divid).innerHTML =
request.responseText;
} else {

alert(request.responseText);

request.responseXML;
}
if(divid > 0) {
document.getElementById("link" + divid).innerHTML =
'<img src="images/forum_collapse.gif" border="0">';

document.getElementById("loadingdiv"+divid).style.visibility =
"hidden";
}
}
}
}

It works great in Firefox - returns some HTML code, exactly as planned.
But in IE, responseText returns nothing and causes an alert that says I
have received a system error, and responseBody returns a huge set of
garbage characters.

What am I doing wrong? I have tried replacing "Msxml2.XMLHTTP" with
"Msxml2.XMLHTTP.5.0" (Another person suggested that) and it doesn't
work....

Help!!!
 
M

Martin Honnen

furby said:
But in IE, responseText returns nothing and causes an alert that says I
have received a system error, and responseBody returns a huge set of
garbage characters.

What is the encoding of the HTML the server sends? MSXML tries to decode
the response body as UTF-8 to build responseText.
 
F

furby

I just did a getAllResponseHeaders() and it returned :
"X-Powered-By: ASP.NET Content-Length: 12906 Content-Type: text/html;
charset=65001"

What I am trying to return is an ASP code generated table (Not even a
whole web page) that I then try to paste into a <DIV> in the page that
calls it...
 
F

furby

I have discovered that it will work in IE if I use "Msxml2.XMLHTTP.4.0"
rather than just a generic "Msxml2.XMLHTTP"....
 
M

Martin Honnen

furby said:
I have discovered that it will work in IE if I use "Msxml2.XMLHTTP.4.0"

Only that is part of MSXML 4 and not generally installed with IE. So
that will work if the browser user is on a system where MSXML 4 was
installed additionally but otherwise not.
 
F

furby

That's weird. I just took a clean laptop, installed IE 6.0.2900.2180 on
it and it works perfectly...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top