Skip to main content

Bug Tracker

Side navigation

#14053 closed bug (notabug)

Opened June 21, 2013 09:03AM UTC

Closed June 23, 2013 04:48PM UTC

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

Reported by: Hrishikesh Moundekar <hrishi.1183@gmail.com> 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;

}

Attachments (0)
Change History (2)

Changed June 21, 2013 09:04AM UTC by Hrishikesh Moundekar <hrishi.1183@gmail.com> comment:1

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

Thanks,

Hrishi

Changed June 23, 2013 04:48PM UTC by dmethvin comment:2

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/