Bug Tracker

Modify

Ticket #2363 (closed bug: worksforme)

Opened 4 years ago

Last modified 4 years ago

$.getJSON() - JSONP callback never gets called

Reported by: iandeth Owned by:
Priority: major Milestone: 1.2.3
Component: core Version: 1.2.3
Keywords: jsonp Cc:
Blocking: Blocked by:

Description

with v1.2.3 + Mozilla Firefox 2.0.0.12, this style of crossdomain $.getJSON() doesn't work, since the callback function never gets called:

$.getJSON( ' http://jquery.com/api/', { callback: '?' }, function (){} );

although this style works fine:

$.getJSON( ' http://jquery.com/api/?callback=?', function (){} );

Here's a demo page:

 http://iandeth.dyndns.org/mt/ian/archives/jquery-1.2.3-JSONP-bug/

the problem in the source code is with the regexp at line 2559:

jsre = /=\?(&|$)/g

and line 2567:

s.data = jQuery.param(s.data);

and line 2580:

s.data.match(jsre)

where s.data ends up with some url encoded string like 'callback=%3F', which doesn't match the jsre regexp.

the old version (v1.2.1) of jsre variable used to have the regexp with url encoded string:

jsre = /=(\?|%3F)/g

so these places should be the placed to be fixed. here's my version of a bug patch code:  http://iandeth.dyndns.org/mt/ian/archives/jquery-1.2.3-JSONP-bug/patch.txt

best, toshi

Change History

comment:1 Changed 4 years ago by davidserduke

That pattern is no longer supported by jQuery.

Look for John's comments in #2020.

comment:2 in reply to: ↑ description Changed 4 years ago by iandeth

thanks for the notice :) i understood the situation very well.

comment:3 Changed 4 years ago by john

  • Status changed from new to closed
  • Resolution set to worksforme

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.