Ticket #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: | ||
| Blocking: | Blocked by: |
Description
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
Change History
comment:2 Changed 4 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:4 Changed 4 years ago by dmethvin
- Status changed from new to closed
- Resolution set to fixed
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.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.


Can you provide a test case?