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!!!
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!!!