Bug Tracker

Ticket #534 (closed bug: fixed)

Opened 2 years ago

Last modified 1 month ago

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

Reported by: void Assigned to: anonymous
Type: bug Priority: major
Milestone: 1.1a Component: ajax
Version: Keywords: onreadystatechange, firefox
Cc: Needs:

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();

Attachments

Change History

Changed 2 years ago by joern

  • status changed from new to closed
  • resolution set to worksforme

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.

Changed 2 years ago by void

  • status changed from closed to reopened
  • resolution deleted

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!

Changed 2 years ago by joern

  • status changed from reopened to closed
  • resolution set to worksforme

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.

Changed 2 years ago by void

  • status changed from closed to reopened
  • resolution deleted

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

Changed 2 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.

Changed 2 years ago by joern

  • status changed from reopened to closed
  • resolution set to fixed

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

Note: See TracTickets for help on using tickets.