Bug Tracker

Opened 14 years ago

Closed 13 years ago

Last modified 11 years ago

#4777 closed bug (fixed)

ajaxStop and ajaxStart not working

Reported by: scarlac Owned by:
Priority: major Milestone: 1.4
Component: unfiled Version: 1.3.2
Keywords: loader, ajax, jsonp, ajaxstart, ajaxstop Cc:
Blocked by: Blocking:


When using jsonp, jQuery.active is decremented twice due to the checks being made.

The reason perhaps lies in that the script.onload handler is called as well as the script.onreadystatechange. both of them decrement the jQuery.active counter.

This results in ajaxStart and ajaxStop being called once and after that the jQuery.active is negative which means neither of them are called afterwards.

I am logging this everywherein jquery.js where jQuery.active is incremented/decremented:

console.log('start, '+s.global + ", " + jQuery.active);
// or this:
console.log('stop, '+s.global + ", " + jQuery.active);

And my output from firebug is:

start, true, -1
GET http://localhost:8000/ap(...)
calling complete in jsonp style
stop in complete, true, -2
calling complete in onreadystatechange generic handler
stop in complete, true, -3

I am using FF 3.0 and jQuery 1.3.2.

Change History (2)

comment:1 Changed 14 years ago by scarlac

My current workaround is to hardcode the following fix just after all the checks:

jQuery.active = jQuery.active < 0 ? 0 : jQuery.active;

This won't fix the *real* issue here (which is that complete() is called twice) but it will work for me and perhaps others. In other words: I wouldn't suggest that as a patch...

Regards Seph

comment:2 Changed 13 years ago by dmethvin

Resolution: fixed
Status: newclosed

Fixed in jQuery 1.4.

Note: See TracTickets for help on using tickets.