Skip to main content

Bug Tracker

Side navigation

#534 closed bug (fixed)

Opened December 17, 2006 10:08AM UTC

Closed December 29, 2006 01:51PM UTC

Last modified October 14, 2008 10:29AM UTC

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();
Attachments (0)
Change History (6)

Changed December 21, 2006 12:54PM UTC by joern comment:1

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.

Changed December 25, 2006 01:57PM UTC by void comment:2

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!

Changed December 28, 2006 12:39PM UTC by joern comment:3

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.

Changed December 28, 2006 02:31PM UTC by void comment:4

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

Changed December 29, 2006 12:02PM UTC by joern comment:5

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

Changed December 29, 2006 01:51PM UTC by joern comment:6

resolution: → fixed
status: reopenedclosed

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