Bug Tracker

Modify

Ticket #12226 (closed bug: invalid)

Opened 10 months ago

Last modified 9 months ago

concurrent jsonp ajax requests with the same jsonpCallback value fail with an undefined callback

Reported by: anonymous Owned by:
Priority: low Milestone: None
Component: ajax Version: 1.8.0
Keywords: Cc:
Blocking: Blocked by:

Description

With an error message: TypeError: 'undefined' is not a function (evaluating 'callback({"count": "3"})')

jsfiddle here:  http://jsfiddle.net/Wn4HH/3/

Additional calls beyond the first appear to overwrite the global callback function.

Change History

comment:1 Changed 9 months ago by sindresorhus

  • Priority changed from undecided to low
  • Resolution set to invalid
  • Status changed from new to closed
  • Component changed from unfiled to ajax
  • Version changed from 1.7.2 to 1.8.0

You're specifying a the name of a callback handler without actually creating it.

From  docs - jsonpCallback:

Specify the callback function name for a JSONP request. This value will be used instead of the random name automatically generated by jQuery. It is preferable to let jQuery generate a unique name as it'll make it easier to manage the requests and provide callbacks and error handling. You may want to specify the callback when you want to enable better browser caching of GET requests. As of jQuery 1.5, you can also use a function for this setting, in which case the value of jsonpCallback is set to the return value of that function.

Example:  http://jsfiddle.net/Wn4HH/4/

Last edited 9 months ago by sindresorhus (previous) (diff)

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.