Skip to main content

Bug Tracker

Side navigation

#3281 closed bug (duplicate)

Opened August 22, 2008 03:18PM UTC

Closed November 13, 2010 08:03PM UTC

Last modified March 14, 2012 09:10PM UTC

double requests in IE when appending script elements

Reported by: arrix Owned by:
Priority: major Milestone: 1.3
Component: ajax Version: 1.2.6
Keywords: Cc: arrix
Blocked by: Blocking:
Description
$(document.body).append($(document.createElement('script')).attr({
  type: 'text/javascript',
  src: 'http://localhost/json.js'
}));

The code above creates a script element, sets attributes and appends it to document using jQuery dom manipulation.

In my IE7, two requests are sent to server.

It turns out that IE7 sends the request right after you set the src attribute even if the script element is not attached to the document tree yet. Then jquery calls evalScript in append, making another request.

Though this is technically not a jQuery bug, it could cause hard to find bugs.

Attachments (0)
Change History (5)

Changed August 30, 2008 07:13AM UTC by arrix comment:1

component: coreajax

Changed January 08, 2009 04:02AM UTC by dmethvin comment:2

cc: → arrix

Depending on the resolution of #3105 the behavior of this test case may change.

Is there a particular reason for creating/appending a DOM element vs doing it all in a string? Or does it happen for that case as well?

Changed January 08, 2009 04:09AM UTC by dmethvin comment:3

Also, this appears like it may be a duplicate of #2612 which reports that the problem only occurs with an absolute URL.

Changed November 13, 2010 08:03PM UTC by dmethvin comment:4

resolution: → duplicate
status: newclosed

Changed November 13, 2010 08:03PM UTC by dmethvin comment:5

Duplicate of #2612.