Ticket #3281 (closed bug: duplicate)
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:2 Changed 4 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 4 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.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
