Bug Tracker

Ticket #3281 (closed bug: duplicate)

Opened 6 years ago

Last modified 2 years ago

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

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.

Change History

comment:1 Changed 6 years ago by arrix

  • Component changed from core to ajax

comment:2 Changed 6 years ago by dmethvin

  • Cc arrix added

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?

comment:3 Changed 6 years ago by dmethvin

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

comment:4 Changed 4 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to duplicate

comment:5 Changed 4 years ago by dmethvin

Duplicate of #2612.

Note: See TracTickets for help on using tickets.