Skip to main content

Bug Tracker

Side navigation

#8398 closed bug (fixed)

Opened February 28, 2011 04:43AM UTC

Closed July 21, 2012 08:43PM UTC

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
Blocked by: Blocking:
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

Attachments (0)
Change History (8)

Changed February 28, 2011 06:25AM UTC by dmuir comment:1

_comment0: Deleting jsonp and jsonpCallback from the 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/1298874400567010
_comment1: Deleting jsonp and jsonpCallback from the repeated request fixes it:[[BR]] \ http://jsfiddle.net/fMt3t/10/ \ \ Likewise, setting jsonp and jsonCallback to null on the original request fixes it:[[BR]] \ http://jsfiddle.net/fMt3t/11/1298876047374940

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/

Changed February 28, 2011 07:38AM UTC by jaubourg comment:2

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.

http://jsfiddle.net/r4juA/1/

Changed February 28, 2011 07:38AM UTC by jaubourg comment:3

cc: → jaubourg

Changed February 28, 2011 07:51AM UTC by dmuir comment:4

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?

Changed February 28, 2011 08:16AM UTC by jaubourg comment:5

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.

Changed March 07, 2011 12:12AM UTC by rwaldron comment:6

component: unfiledajax

Changed March 07, 2011 01:43AM UTC by rwaldron comment:7

priority: undecidedlow
status: newopen

Changed July 21, 2012 08:43PM UTC by mikesherov comment:8

milestone: 1.next1.6.4
resolution: → fixed
status: openclosed

This appears to have been fixed as of 1.6.4: http://jsfiddle.net/fMt3t/80/