Skip to main content

Bug Tracker

Side navigation

#13665 closed bug (cantfix)

Opened March 26, 2013 12:16PM UTC

Closed March 26, 2013 12:23PM UTC

Concurrent jsonp requests with same callback fails persistently

Reported by: tom.gallard@norlandtech.com Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:
Description

Test case: http://jsfiddle.net/EkuuU/5/

The Jsonp ajax prefilter replaces the function to be called (in this case 'jsonpCallbackWithDelay' with its own function (line 8397 of jquery 1.9.1 ).

It then swaps the function back (line 8405) after the script has been downloaded and executed.

This causes a problem if there are two overlapping jsonp requests using the same callback function:

1.) Req 1 enters preFilter, and callback function is replaced by jquery function. Original function is stored in 'overwritten' variable.

2.) Req 2 enters preFilter and the callback function is replaced. However- as it has already been replaced in 1.), and not swapped back, the 'overwritten' variable ends up containing the jquery function rather than the original.

3.) Req 1 cleanup function (line 8405) is called, and tries to replace the original function. However as overwritten contains the wrong function, the original function is not replaced.

Attachments (0)
Change History (1)

Changed March 26, 2013 12:23PM UTC by jaubourg comment:1

resolution: → cantfix
status: newclosed

This is a known limitation of the jsonp implementation in jQuery. Getting around it implies a lot more trickeries than meets the eye and cannot be achieved without browser sniffing which is a no go in jQuery core. If you wanna have finer control over jsonp requests, use https://github.com/jaubourg/jquery-jsonp