Bug Tracker

Ticket #8398 (closed bug: fixed)

Opened 4 years ago

Last modified 2 years ago

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:1 Changed 4 years ago by dmuir

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/

Last edited 4 years ago by dmuir (previous) (diff)

comment:2 Changed 4 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.

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

comment:3 Changed 4 years ago by jaubourg

  • Cc jaubourg added

comment:4 Changed 4 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 4 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:6 Changed 4 years ago by rwaldron

  • Component changed from unfiled to ajax

comment:7 Changed 4 years ago by rwaldron

  • Priority changed from undecided to low
  • Status changed from new to open

comment:8 Changed 2 years 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/

Note: See TracTickets for help on using tickets.