Ticket #8398 (closed bug: fixed)
regression: invalid label on repeat ajax request
| Reported by: | dmuir | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 1.6.4 |
| Component: | ajax | Version: | 1.5.1 |
| Keywords: | Cc: | jaubourg | |
| Blocking: | Blocked by: |
Description
When a repeat ajax request expects a json response, the json parsing fails on the 2nd response.
http://jsfiddle.net/fMt3t/9/ Works in 1.4.2, but doesn't work in any version of jQuery since.
Might be related to: http://bugs.jquery.com/ticket/7461
Change History
comment:2 Changed 2 years ago by jaubourg
Your json request gets promoted to a jsonp request the second time around because you now have the jsonp and jsonpCallback options from ajaxSettings in there.
comment:4 Changed 2 years ago by dmuir
But why are those options being added? And regardless of them being there, it shouldn't be using them since the dataType is json, not jsonp, right?
comment:5 Changed 2 years ago by jaubourg
These options are added because the options map you're getting within the callbacks is the fully constructed, internal, one (including the options provided to ajax AND the options in ajaxSettings).
And the json request gets promoted as a jsonp request because ajax allows stuff like:
$.ajax({
url: "...",
dataType: "json",
jsonp: "callbackParameter"
});
// OR
$.ajax({
url: "...",
dataType: "json",
jsonpCallback: "myCallbackName"
});
I could live without it, to be honest, but it made the transition from 1.4.x to 1.5.x for compatibility reasons.
comment:7 Changed 2 years ago by rwaldron
- Priority changed from undecided to low
- Status changed from new to open
comment:8 Changed 10 months ago by mikesherov
- Status changed from open to closed
- Resolution set to fixed
- Milestone changed from 1.next to 1.6.4
This appears to have been fixed as of 1.6.4: http://jsfiddle.net/fMt3t/80/
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Deleting jsonp and jsonpCallback from the repeated request fixes it:
http://jsfiddle.net/fMt3t/10/
Likewise, setting jsonp and jsonCallback to null on the original request fixes it:
http://jsfiddle.net/fMt3t/11/
Lastly, using jQuery.ajaxSetup() to remove jsonp and jsonpCallback
http://jsfiddle.net/fMt3t/12/