Bug Tracker

Modify

Ticket #7017 (closed bug: duplicate)

Opened 4 years ago

Last modified 2 years ago

Global Ajax Events ajaxSend, ajaxSuccess, ajaxError and ajaxComplete do not work

Reported by: zorneck Owned by:
Priority: undecided Milestone:
Component: ajax Version: 1.4.2
Keywords: global ajax events Cc:
Blocking: Blocked by:

Description

The global ajax events ajaxSend, ajaxSuccess, ajaxError and ajaxComplete do not work since version 1.4.0. The events ajaxStart and ajaxStop works fine.

Example:

$('body').ajaxSuccess(function() {

alert('test');

});

this do not work!

I hope it will be fixed until version 1.4.3

Attachments

mytest.js Download (954 bytes) - added by zorneck 4 years ago.
The javascript test code
index.html Download (422 bytes) - added by zorneck 4 years ago.
The test start page
ajaxtest.html Download (31 bytes) - added by zorneck 4 years ago.
Something to reload

Change History

comment:1 Changed 4 years ago by john

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

Do you have more details? They appear to work in all of your test cases.

comment:2 Changed 4 years ago by zorneck

  • Status changed from closed to reopened
  • Resolution worksforme deleted

I currently use version 1.4.2. I tested these events in firefox 3.6.9 and in Chrome.

In the meantime I searched the source code of jQuery 1.4.2 for these events, and found, that they are called wrong, I think.

The working events ajaxStart and ajaxStop are called by e.g.: jQuery.event.trigger("ajaxStart");

The other global ajax events are called e.g.: trigger("ajaxSuccess");

I think the last example is the bug. Please test it, and you will see it.

comment:3 Changed 4 years ago by john

  • Status changed from reopened to closed
  • Resolution set to worksforme

No, that is to be expected - start and stop are different from the success/complete/error events.

As mentioned before, we already do test this and, in fact, have very good coverage:  http://github.com/jquery/jquery/blob/master/test/unit/ajax.js

A specific test case will be required in order to examine this further.

comment:4 Changed 4 years ago by zorneck

  • Status changed from closed to reopened
  • Resolution worksforme deleted

Ok, I found out, what the problem is, I set the context to this ('this' is in this case my object that makes the ajax call):

jQuery.ajax({

url: 'some_url.html', context: this

});

In this case the mentioned global ajax events will not work. Is this a bug, or should it be like this?

comment:5 Changed 4 years ago by jishan

I can confirm this bug. jQuery 1.4.2 doesn't fire any ajax callbacks on Firefox 4 beta 6 while the older version 1.3.2 works fine. It also works fine on FF 3.6.10.

Changed 4 years ago by zorneck

The javascript test code

Changed 4 years ago by zorneck

The test start page

Changed 4 years ago by zorneck

Something to reload

comment:6 Changed 4 years ago by zorneck

I added my test code, where you can see the problem. When you click the "Start Ajax Test" button the global events ajaxSend, ajaxSuccess, ajaxError and ajaxComplete will not fire. The reason for this is the changed context of the ajax call.

comment:7 Changed 4 years ago by zorneck

Here is my  jsFiddle Test.

Run the test, click on "Start Ajax Test", and see that the global ajax events ajaxSend, ajaxSuccess, ajaxError and ajaxComplete do not work (no alert will be called).

comment:8 Changed 3 years ago by snover

  • Milestone 1.4.3 deleted

Resetting milestone to future.

comment:9 Changed 3 years ago by snover

  • Priority set to undecided
  • Status changed from reopened to closed
  • Resolution set to duplicate

comment:10 Changed 3 years ago by snover

Duplicate of #6161.

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.