Bug Tracker

Opened 7 years ago

Closed 7 years ago

#12226 closed bug (invalid)

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

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 (1)

comment:1 Changed 7 years ago by sindresorhus

Component: unfiledajax
Priority: undecidedlow
Resolution: invalid
Status: newclosed
Version: 1.7.21.8.0

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

From docs:

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/

Version 0, edited 7 years ago by sindresorhus (next)
Note: See TracTickets for help on using tickets.