Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 11 years ago

#534 closed bug (fixed)

success-event not fired on synchronous AJAX events on FF (with fix)

Reported by: void Owned by:
Priority: major Milestone: 1.1a
Component: ajax Version:
Keywords: onreadystatechange, firefox Cc:
Blocked by: Blocking:

Description

If you do an non-asynchronous AJAX request, like so:

$.ajax({'async':false,'url':'ajax.txt',success:function(data){alert(data)}});

then the 'success' function is not called on FireFox (1.5.0.8 on WinXP). This is because Firefox does not fire the 'onreadystatechange' event on synchronous ajax calls. The fix is easy, just change 2 lines of code:

Line 1975 in jquery-1.0.4.js:

if(s.async) xml.onreadystatechange = onreadystatechange;

Line 1994 in jquery-1.0.4.js:

if (!s.async) onreadystatechange();

Change History (6)

comment:1 Changed 13 years ago by joern

Resolution: worksforme
Status: newclosed

I can't confirm this (with FF 1.5.0.9). This is the test code:

test("synchronous request with callbacks", function() {
	var result;
	$.ajax({url: "data/json.php", async: false, success: function(data) { result = data; }});
	ok( /^{ "data"/.test( result ), "check returned text" );
});

Please reopen if the problem persists.

comment:2 Changed 13 years ago by void

Resolution: worksforme
Status: closedreopened

The problem does persist... If you search Google Groups, you will find many reports about this issue: Firefox does not fire the onreadyStateChange on syncrhonous AJAX requests.

Examples: Example1 and Example2

Once again, my example is this:

$.ajax({async:false,url:'ajax.txt',success:function(data){alert(data)}});	

Tested on FF 1.5.0.9 on WinXP and on FF 1.5.0.7 on Linux: both do not call the 'success' function.

Please test it as in this example, I'm sure you will find the same results. Thanks!

comment:3 Changed 13 years ago by joern

Resolution: worksforme
Status: reopenedclosed

Your example works just fine. Did you try if it works with "async: true"? Maybe the problem is elsewhere. Otherwise: Please setup a test page that clearly shows the problem.

comment:4 Changed 13 years ago by void

Resolution: worksforme
Status: closedreopened

Alright, here's the online example for ya:

http://zooi.arjan.webpower.nl/jquery/

Need more info? I am more than willing to answer your questions. Contact me at arjan -the well known separator- avoid dot org

comment:5 Changed 13 years ago by joern

Interesting. My guess: This was fixed in FF 2, therefore it works for me. Got to install FF 1.5 again.

comment:6 Changed 13 years ago by joern

Resolution: fixed
Status: reopenedclosed

Fixed in SVN. It is a FF1.5 only-problem, but now handled by jQuery.

Note: See TracTickets for help on using tickets.