Side navigation
#3442 closed enhancement (fixed)
Opened October 03, 2008 10:25AM UTC
Closed January 09, 2011 03:58PM UTC
Last modified March 15, 2012 12:41AM UTC
JSONP should provide abort method
Reported by: | tr4nslator | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.5 |
Component: | ajax | Version: | 1.3.2 |
Keywords: | jsonp,ajax | Cc: | |
Blocked by: | Blocking: |
Description
As discussed here:
http://groups.google.com/group/jquery-dev/browse_thread/thread/e313b7f8ae5948cb
Currently, there's no easy way to abort a JSONP call once it's been fired, because no reference to the window-scoped callback function (or injected script tag) is returned. Just as an XHR request returns the XHR object, JSONP calls should return a handler that allows callback cancellation.
(It would be nice to see this implemented along with something like this too: http://dev.jquery.com/ticket/1863)
Attachments (1)
Change History (12)
Changed October 04, 2008 04:11PM UTC by comment:1
cc: | → tr4nslator, flesler |
---|---|
component: | unfilled → ajax |
owner: | flesler |
Changed October 09, 2008 12:46AM UTC by comment:2
Here is patch to add aborts for JSONP and script call. Also adds timeout support as suggested in #1863
Changed January 08, 2009 06:57PM UTC by comment:3
The complete() callback isn't invoked upon timeout. This can probably be fixed by adding a call to complete() at the end of the timeout function.
Changed November 12, 2009 03:07PM UTC by comment:4
milestone: | 1.3 → 1.4 |
---|---|
type: | bug → enhancement |
version: | 1.2.6 → 1.3.2 |
Changed February 01, 2010 10:52AM UTC by comment:5
I am waiting for this feature for more than a year. It's milestone is set to 1.4 but apparently is is not fixed in jQuery 1.4. There is a plugin that can be used instead: http://code.google.com/p/jquery-jsonp/
Changed March 17, 2010 03:47PM UTC by comment:6
When testing JSONP it seems the callbacks are executed in the order the JSONP requests were made. It's easy to see why, because the browser will execute <script> tags in order. This is problematic when early JSONP calls may take longer than later ones though. An abort() method would be very handy to stop these earlier (and no longer needed) calls from blocking later ones.
My particular use case is an autocomplete field that needs to run on any site (hence JSONP). The early calls tend to take longer because they produce more results e.g. all places starting with "L". Later ones are faster e.g. all places starting with "Londo".
Changed November 06, 2010 11:22PM UTC by comment:7
Unless I understand the patch incorrectly, this change does not truly abort the request. Instead, it simply sets a flag that tells the request it was aborted *once it returns* if it takes more than the timeout period. That is an important difference because the request is still "in flight" after being aborted and is taking up one of the connections to that domain.
IE6/7 in particular only allows two connections per domain by default. Subsequent JSONP requests to that domain will queue until the browsers gives up on the "aborted" requests. http://msdn.microsoft.com/en-us/library/cc304129%28VS.85%29.aspx
Changed November 10, 2010 04:41PM UTC by comment:8
milestone: | 1.4 → 1.5 |
---|---|
priority: | major → low |
status: | new → open |
There is additional discussion in the W3C on the order of script execution upon dynamic insertion. It may be wise to wait for that. It may be worthwhile to add the async
attribute to the scripts that are injected with jsonp. That may already solve some ordering issues.
Changed December 27, 2010 10:36PM UTC by comment:9
keywords: | jsonp ajax → jsonp,ajax,ajaxrewrite |
---|
Changed January 09, 2011 03:58PM UTC by comment:10
resolution: | → fixed |
---|---|
status: | open → closed |
You can abort any request, no matter its type in the new ajax.
Changed January 28, 2011 01:06AM UTC by comment:11
cc: | tr4nslator, flesler |
---|---|
keywords: | jsonp,ajax,ajaxrewrite → jsonp,ajax |
Changed March 15, 2012 12:41AM UTC by comment:12
In what version is this actually fixed?
In version 7.1 the abort function does not abort the actual call back for jsonp request, jquery fires off the error function like it should and its status is aborted, but the call is still active and holding an open connection to the server.