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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AJAX / Firefox crashing on close() response

Status
Not open for further replies.
Mar 3, 2006
25
My onreadystatechange is calling the function updatePage(see below.)
Code:
function updatePage() {
  if(document.getElementById('readystate')){
    document.getElementById('readystate').innerHTML='Ready State is '+doc.readyState;
  }
  if (doc.readyState == 4) {
    if (doc.status == 200) {
      var response = doc.responseText.split("|");
      if (response[0]!="") {
        eval(response[0]);
      }
    } else {
      if(tried<3) {
        getXML(file,str); tried++;
      } else {
        alert("Status code " + doc.status+"\n"+
        "Server connection appears to be\n"+
        "down.  Try re-entering your request.");
        close();
      }
    }
  }
}
response[0] js script returned by the server is
Code:
if(opener.prm06)opener.prm06['04']['posted']='2006-06-02';
if(opener.prm06)opener.prm06['04']['uid']='john';
window.close();
Everything works in IE but in FireFox the child hangs on the window.close() statement. If I click on the window that was suppose to close ALL Firefox (even unrelated) windows close. If I leave the winodw.close() statement out of the return code I can close the window manually without crashing FF.

Any suggestions
Rois
 
Dan,
I added
Code:
function myClose(){
window.close();
}
to my page and changed my scripts to use window.myClose
and changed the server returned code to be
Code:
if(opener.prm06)opener.prm06['04']['uid']='john';
window.myClose();

But it's still crashing ALL FF windows.
Thoughts?
Rois
 
You have anotehr close function though, I thought:

Code:
      if(tried<3) {
        getXML(file,str); tried++;
      } else {
        alert("Status code " + doc.status+"\n"+
        "Server connection appears to be\n"+
        "down.  Try re-entering your request.");
        [!]close();[/!]
      }

Is that what you were previously calling?

Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
That was an error. Should have been window.close(); but the script isn't hitting that in this instance since ajax is connecting and getting a response back.

I got it to work correctly by replacing window.myClose(); with self.setTimeout('window.close();',500); in the server return response.

Why do you suppose making it wait 1/2 a second makes it work? Not finished with the previous command before trying to close crashes js???
Thanx
Rois
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top