By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,568 Members | 1,194 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,568 IT Pros & Developers. It's quick & easy.

Problems with IE returning nothing in responseText

P: n/a
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).sty le.visibility
= "visible";
if(document.getElementById("srchon").value == "YES") {
var url =
"forum_api.asp?pageaction=GETLEVEL&forumid=<%=requ est("forumid")
%>&parentid=" + parentid + "&srch=" +
document.getElementById("srchterm").value;
} else {
var url =
"forum_api.asp?pageaction=GETLEVEL&forumid=<%=requ est("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!!!

Sep 13 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a


furby wrote:
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.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 13 '06 #2

P: n/a
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 <DIVin the page that
calls it...
Martin Honnen wrote:
furby wrote:
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.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 13 '06 #3

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

furby wrote:
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).sty le.visibility
= "visible";
if(document.getElementById("srchon").value == "YES") {
var url =
"forum_api.asp?pageaction=GETLEVEL&forumid=<%=requ est("forumid")
%>&parentid=" + parentid + "&srch=" +
document.getElementById("srchterm").value;
} else {
var url =
"forum_api.asp?pageaction=GETLEVEL&forumid=<%=requ est("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!!!
Sep 13 '06 #4

P: n/a


furby wrote:
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.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 14 '06 #5

P: n/a
That's weird. I just took a clean laptop, installed IE 6.0.2900.2180 on
it and it works perfectly...
Martin Honnen wrote:
furby wrote:
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.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 18 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.