Possible bug in firefox? (AJAX related)

Soldato
Joined
20 Oct 2002
Posts
3,469
Location
London, UK
Hey all,

I've been banging my head against a brick wall on this one for the last 12 hours, and the time has come for me to give up and consult the gurus on this one.

The below URL contains a login page, you can test it using the details
User: marco
Pass: polo

This seems to work PERFECTLY in opera, and it works in firefox but ONLY if I have firebug enabled. I don't care about IE for now, I'll sort that out later.

URL: http://www.doc.ic.ac.uk/project/2006/271/g0627142/test/index.htm

The problem lies in the fact that despite the ajax readyState variable evidently changing (as you can see in the debug alert popups), it never executes the code defined by onreadystatechange.

If you view in Opera, you'll be able to see that an alert box pops up each time the onreadystatechange is triggered.

Can anybody help me? I've consulted google many times and this particular problem doesn't seem to be discussed anywhere.
 
Last edited:
Code:
ajaxRequest.open("POST", desturl, false);
Try making the request asynchronous (third param to true) so the script doesn't wait for a reply from the server. Firebug has done stuff like this to me in past versions and needed its options changed.
 
I'm no JS coder but surely the problematic line should be

Code:
ajaxRequest.onreadystatechange = ajaxRequestHandler();

And secondly if you are too assign something to a function call the function should return something which it does not, or maybe im missing something here?
 
Thanks for the replies so far chaps :)

psyr33n said:
Code:
ajaxRequest.open("POST", desturl, false);
Try making the request asynchronous (third param to true) so the script doesn't wait for a reply from the server. Firebug has done stuff like this to me in past versions and needed its options changed.
yeah I have tried that but it doesn't seem to change the fact that onreadystatechange doesnt trigger.

I was thinking perhaps the problem might be because the request is sent using a POST method rather than GET, but I want it to be POST :(

I have now got it working perfectly in IE too, turns out the only thing wrong with it as far as IE was concerned was because I was using some "const" declarations instead of "var" to define some constants, which IE apparently doesn't like.

In its current state, it works perfectly with:
Firefox (only with firebug addon running)
IE
Opera

I haven't tested other browsers, but IE and 2 different mozilla's is a good start I reckon :)
 
I had a similar problem (ajax only working with firebug on). I don't have the time now to look at your code, but my issue was that I had the line:

Code:
var xmlhttpreq = false;

in my code where I intialized the XMLHttpRequest object. Removing this line fixed the problem.

*edit* I came back to it - you have the line:

Code:
ajaxRequest = false;

Remove it, see what happens.
 
But in the JS he's simply setting ajaxRequest to a boolean false as a precursor, or strict declaration of variables: he then has the exception try/catch block to set it to an XHR object. So in most browsers ajaxRequest is going to be an object, not a boolean as first explicitly defined.
 
psyr33n said:
But in the JS he's simply setting ajaxRequest to a boolean false as a precursor, or strict declaration of variables: he then has the exception try/catch block to set it to an XHR object. So in most browsers ajaxRequest is going to be an object, not a boolean as first explicitly defined.

I'm not saying it isn't a bug and that FF isn't handling the JS correctly, I'm just suggesting a possible fix to get it working.
 
Back
Top Bottom