Skip to main content

Bug Tracker

Side navigation

#9687 closed bug (duplicate)

Opened June 28, 2011 05:09PM UTC

Closed June 30, 2011 03:58PM UTC

Last modified June 30, 2011 03:58PM UTC

$.getScript() equiv $.ajax() with timeout - timeout elapsed, error() fired, script still executed

Reported by: anonymous Owned by: anonymous
Priority: low Milestone: 1.next
Component: ajax Version: 1.5.2
Keywords: Cc:
Blocked by: Blocking:
Description

BUG: An $.ajax()-retrieved script is loaded/executed even after the ajax timeout is expired.

With $.ajax({dataType: 'script', type: 'GET', timeout: 10000}, success: ..., error: ...), the target script, if eventually retrieved, is executed even after the timeout has elapsed and the error handler has been executed. (That is long-hand code for $.getScript() with timeout and error handling added)

It should be easy enough to statically analyze for someone familiar with the $.ajax code. It is too difficult a situation to create a public test case for this because of the requirements, jsfiddle.net cannot handle it.

The usecase is to connect to a COMET server with $.getScript() which works well unless a timeout is specified (with the $.ajax({dataType: 'script'}) equivalent call) and the timeout is elapsed. In this case of the timeout elapsing, error() is run (as expected), firebug shows that the browser continues to wait for a result from the server, and once retrieved, jquery executes it without respect to the "timeout" or "abort" status.

I believe the fix needs to be in $.ajax's function done( status, statusText, responses, headers ) but I'm not familiar enough with this code to attempt the change.

[=#COMET]COMET::

A COMET server is a special webserver implementation which holds browser connections open until an event of interest to the client occurs, at which time a payload either of code or data can be returned to the browser. Code is preferred because it avoids the need for a parser on the client-side.

Attachments (0)
Change History (4)

Changed June 28, 2011 06:01PM UTC by anonymous comment:1

I assume that this happens with any content type, except that normally only the success callback is used to process it. With a dataType: 'script', it can run without being officially invoked by the user code.

Changed June 29, 2011 07:15PM UTC by timmywil comment:2

component: unfiledajax
owner: → anonymous
priority: undecidedlow
status: newpending

Thanks for taking the time to contribute to the jQuery project! Do you perhaps have a running test case anywhere?

Also, please be sure you are testing against the git version of jQuery to ensure the issue still exists.

Changed June 30, 2011 03:58PM UTC by jaubourg comment:3

resolution: → duplicate
status: pendingclosed

This is a FF bug: when you remove a script tag from the document, the resource is still fetched.

Changed June 30, 2011 03:58PM UTC by jaubourg comment:4

Duplicate of #8744.