Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XMLHttpRequest won't work in Firefox 1

Status
Not open for further replies.

roblasch

Programmer
Dec 30, 2000
168
US
Can anyone explain why this works in ie, but not firefox?
From editing this code and substituting alert statements, it seems that the readystate never gets past 1, but I don't see why.

function objConstruct(url,obj){
this.url=url;
this.lyr=document.getElementById(obj);
this.conn=createRequest(this);
}

function createRequest2(obj){
try {
obj.conn = new XMLHttpRequest();
}catch(trymicrosoft){
try{
obj.conn = new ActiveXObject("Msxml2.XMLHTTP");
}catch (othermicrosoft) {
try{
obj.conn = new ActiveXObject("Microsoft.XMLHTTP");
}catch (failed) {
obj.conn = false;
}
}
}
if (!obj.conn){
alert("Error initializing XMLHttpRequest!");
}else{
obj.conn.open("GET", obj.url, true);
obj.conn.onreadystatechange = function(){
if (obj.conn.readyState == 4){
if (obj.conn.status == 200){
obj.lyr.innerHTML+=obj.conn.responseText;
obj.lyr.style.width="98%";
obj.lyr.style.position="relative";
}
}
}
obj.conn.send(null);
}
}
var xmlhttp=new objConstruct("page.htm","layerID");
 
Where is "createRequest2" ever being called? You also have a call to a "createRequest" function that doesn't exist.

NB: There is now an AJAX-specific forum: forum1600

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Apart from an obvious typo, your construction of the object is _no good_. You pass this to the createRequest2 to return this.conn, and then you are setting us effectively obj.conn in the method. All seems terrible mixed up and self-confusing. A quick clean up would be just call createRequest2 as a function.
[tt] [red]//[/red]this.conn=createRequest(this);
createRequest2(this);[/tt]
At certain moment, you may be, or maybe not, requested to give privilege in moz. But, it depends.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top