Bug Tracker

Modify

Ticket #2612 (closed bug: invalid)

Opened 5 years ago

Last modified 2 years ago

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

Description

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.

Jerome

Attachments

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

Change History

Changed 5 years ago by jwagner

comment:1 Changed 4 years ago by brandon

  • Component changed from ajax to core

comment:2 Changed 4 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 3 years ago by dmethvin

#3281 is a duplicate of this ticket.

comment:5 Changed 3 years ago by SlexAxton

  • Owner set to jwagner
  • Priority changed from major to low
  • Status changed from new to pending
  • Component changed from core to ajax
  • Milestone changed from 1.2.4 to 1.4.5

Can someone verify that this is still an issue?

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

  • Status changed from pending to closed
  • Resolution set to invalid

Automatically closed due to 14 days of inactivity.

comment:7 Changed 2 years ago by john

  • Version changed from 1.2.3 to 1.5

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

comment:8 Changed 2 years ago by john

  • Milestone changed from 1.4.5 to 1.5

There was no 1.4.5 release, was actually 1.5.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.