Bug Tracker

Opened 14 years ago

Closed 14 years ago

#4086 closed bug (fixed)

$().load() & $.ajaxSetup bug

Reported by: mk Owned by:
Priority: minor Milestone: 1.3.2
Component: ajax Version: 1.3.1
Keywords: Cc:
Blocked by: Blocking:


In my main .js file i have this line (I use it to show loading image at beginning of ajax request and hide it when it finishes).

$.ajaxSetup({dataType:'json', beforeSend:function() { loading.show(); }, complete:function() { loading.hide(); }})

It works fine with $.post(), $.get()... but when using $().load() it will only show loading, it won't hide it. I tried to put alert() instead of loading functions, only one alert is shown.

Attachments (1)

jQueryLoadTestCase.rar (1.4 KB) - added by mk 14 years ago.
Test example

Download all attachments as: .zip

Change History (5)

comment:1 Changed 14 years ago by dmethvin

Can you provide a test case?

Changed 14 years ago by mk

Attachment: jQueryLoadTestCase.rar added

Test example

comment:2 Changed 14 years ago by mk

Yes, here you can test it online: http://www.mma-studio.com/jQueryLoadTestCase/

I've also attached this as rar archive.

comment:3 Changed 14 years ago by zitiger

I find this problem today, can someone verify it?

comment:4 Changed 14 years ago by dmethvin

Resolution: fixed
Status: newclosed

The jQuery.load method calls jQuery.ajax with its own complete handler, which overrides the one that would have come in through jQuery.ajaxSettings. However, if you were to have used the success handler then load would work and the others would fail.

Instead of using jQuery.ajaxSettings to set handlers, you should be using the ajax global events such as ajaxComplete. I've edited the docs to make this a bit clearer.

Note: See TracTickets for help on using tickets.