Bug Tracker

Modify

Ticket #4777 (closed bug: fixed)

Opened 4 years ago

Last modified 15 months ago

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:
Blocking: Blocked by:

Description

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

comment:1 Changed 4 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 3 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in jQuery 1.4.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.