Bug Tracker

Opened 15 years ago

Closed 12 years ago

Last modified 12 years ago

#2612 closed bug (invalid)

domManip is not always respecting script execution order on IE7

Reported by: jwagner Owned by: jwagner
Priority: low Milestone: 1.5
Component: ajax Version: 1.5
Keywords: script ajax getScript domManip Cc:
Blocked by: Blocking:


Hello, I have an application where I have several script nodes that I append on a node.

When those script elements have a relative src, jquery-1.2.4 manages to execute them synchronously and in the correct order. From what I understand, this is the expected behavior.

But when the script elements have an absolute src, IE7 does not wait for the synchronous execution of the nodes. This leads to random problems in IE7 when a function that is defined in a remote script is called in another inline script element.

Attached is a proposed patch to execute the scripts on a callback chain, using jQuery.getScript when necessary.

I hope this patch suits your coding standards and that you will also consider that the jquery-1.2.3 behavior on this point is a bug.

I can adapt it if you give me some advice because I would really like to have it incorporated in the next jquery release as it fixes a bug on my application.


Attachments (1)

jquery-1.2.3-script-exec-order.patch (2.3 KB) - added by jwagner 15 years ago.

Download all attachments as: .zip

Change History (8)

Changed 15 years ago by jwagner

comment:1 Changed 14 years ago by brandon

Component: ajaxcore

comment:2 Changed 14 years ago by barrettas

This bug is related to using the XMLHttpRequest object to load scripts when the script src is of the same domain as the page. I came across the same problem in jQuery 1.2.6 when trying to make an AJAX widget which loads in pages of different and same domains. When loading on a location that has a different host it worked fine because synchronous loading was honored, but when loading from a location that had the same host it broke due to jQuery thinking all dynamically inserted scripts were loaded before they actually were. I traced the problem to be in the ajax function where the code checks if the script src is for the same domain and if not it loads via inserted script elements, which works while also adhering to the synchronous flag. I'm not sure why it was decided to load scripts differently when on a different domain? Note that I got around the problem by using the following hack:

eval("var location={host: \"lame_hack\",protocol:window.location.protocol};now=jQuery.now;jsc=jQuery.now();jQuery.ajax=" + jQuery.ajax.toString());

What I am doing is reevaluating the ajax function and placing a location variable in scope which contains a host field that will never match the current host. This causes all scripts to take the code route where they get loaded via script element insertion and thus synchronous loading is honored.

comment:4 Changed 12 years ago by dmethvin

#3281 is a duplicate of this ticket.

comment:5 Changed 12 years ago by SlexAxton

Component: coreajax
Owner: set to jwagner
Priority: majorlow
Status: newpending

Can someone verify that this is still an issue?

comment:6 Changed 12 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

Automatically closed due to 14 days of inactivity.

comment:7 Changed 12 years ago by john


There wasn't a 1.4.5 release, was actually 1.5.

comment:8 Changed 12 years ago by john


There was no 1.4.5 release, was actually 1.5.

Note: See TracTickets for help on using tickets.