Bug Tracker

Opened 6 years ago

Closed 6 years ago

#14053 closed bug (notabug)

ajaxStart Event is ignored for the first time when ajax function is called from JQuery

Reported by: Hrishikesh Moundekar <hrishi.1183@…> Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.3
Keywords: Cc:
Blocked by: Blocking:

Description

The ajaxStart Event is ignored for the first time when ajax function is called from JQuery.

Below is the sample code which ran with JQuery 1.8.3

$.ajax({

type : 'get', url : 'tasks.json', dataType : 'json', });

$(this).ajaxStart(function(){

console.log("ajaxStart");

}); $(this).ajaxStop(function(){

console.log("ajaxStop");

});

when you run this code... for the first time the ajaxStart event will be ignored and direct ajaxStop event will be called.. but for all other successive call's the ajaxStart event is also getting triggered... Basic Investigation based of JQuery 1.8.3 version :

below code inside trigger function is avoiding ajaxStart event to get executed and this is because for the first time when we trigger ajaxStart event its not present under jQuery.event.global Array list..

if ( (!elem
jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {

No jQuery handlers for this event type, and it can't have inline handlers

return; }

Change History (2)

comment:1 Changed 6 years ago by Hrishikesh Moundekar <hrishi.1183@…>

The issue is more or less same as Ticket #11038 - PROBLEM WITH AJAXSTART IN 1.7.1.. which is closed without resolution

Thanks, Hrishi

comment:2 Changed 6 years ago by dmethvin

Resolution: notabug
Status: newclosed

See the jQuery 1.9 upgrade guide. The event is only fired on document. Also use the jQuery Migrate plugin.

https://github.com/jquery/jquery-migrate#readme

http://jquery.com/upgrade-guide/1.9/

Note: See TracTickets for help on using tickets.