Skip to main content

Bug Tracker

Side navigation

#2923 closed bug (duplicate)

Opened May 22, 2008 05:54PM UTC

Closed March 18, 2009 10:22PM UTC

Last modified March 14, 2012 03:51PM UTC

getScript and globalEvals fail in IE6 on jQuery 1.2.5 (includes fix)

Reported by: Crash1hd Owned by: brandon
Priority: critical Milestone: 1.3
Component: core Version: 1.2.5
Keywords: Cc:
Blocked by: Blocking:
Description

ok when using getScript() with a remote domain there are 2 errors in IE6 one it aborts the js file being returned and 2 it says invalid argument. I have noticed other bug reports indicating the same thing and they where patched in 1.2.5 however I dont think they where done right

in this one

reference to other ticket:[http://dev.jquery.com/ticket/2709]

They indicated on using

'''head.insertBefore( script, head.firstChild );'''

which works but doesnt actually do what you want it to do which is add the code at the end. to make it add the code at the end you need to do the following

the insert at the end is fine with

'''head.insertChild(script)'''

thats ok the issue was with the head.removeChild(script) would fail what you want to do is this

'''script.parentNode.removeChild(script)'''

that allows the script to be added at the end of the head tag where you want it so that all other scripts run before and you can run stuff in the custom added script and works with basehref as well :)

that code above needs to be applied to every location where you use head.removeChild(script); so thats on lines: 644, 2621, 2672 see link below for reference to this code

Reference: http://groups.google.com/group/alt.comp.lang.javascript/browse_thread/thread/2380af22f06b05a6/475ae9c43505c581

that is only the first problem now to deal with why IE6 aborts the call to test.js on a remote server (no other browser does) well it seems to be an issue of timing so in the jQuery core on line 2677 is this code head.appendChild(script) i have replaced that with this

var IEAbortedFix = function(){
	head.appendChild(script);
}
setTimeout(IEAbortedFix,10);

and it seems that for the timeout it can be any number between 1 and 23. Anything less or more causes an error on the removeChild code

I have included a test case but you will need 2 servers and need to rename the calls to http://www.sitea.com and http://www.siteb.com to the 2 servers you are using.

Attachments (1)
Change History (7)

Changed May 22, 2008 06:39PM UTC by flesler comment:1

owner: → flesler
status: newassigned

Changed June 02, 2008 07:52AM UTC by Crash1hd comment:2

I need to add a note about this, not sure if you have had a chance to test it out yet but I have to note that once adding the above it actually broke in IE7 (I thought I had it working but then it wasnt) so what I realized is that the setTimeout delay was causing issues with the removal of the script tag as it had not been added yet to the dom from the delay in IE7 at least so by doing the following that fixed it :)

so on line 2678 where i had script.parentNode.removeChild(script) i had to update it to this

var IEAbortedFix2 = function(){
	script.parentNode.removeChild(script);
}
			
setTimeout(IEAbortedFix2,10);

by adding the same delay causes IE7 to wait for the removal till after the code is added. A fix for the fix lol

which also means that now you could probably set the delay time greater then 23 now as obviously that was the length of time that IE6 was taking to add the code any longer and it was calling the remove before the add happened!

Changed June 04, 2008 12:45AM UTC by Crash1hd comment:3

I would also like to note that the 2nd issue is only ever an issue inside a click event as I have tried the same code above but on page load and its fine.

Changed October 10, 2008 06:03AM UTC by rberger comment:4

It looks like this bug is also in 1.2.6. And that the same change needs to be done to line 2626 as well.

This showed up for me when doing IE6 getJSON calls along the lines of:

var url = base_url + "/jsonfetch/" + message_file + "_json?format=json&cCallback=?";
$j.getJSON(url, function(data) {
         $j(content_jq).html(data.html);
}

Changed January 22, 2009 09:38PM UTC by ricardoe comment:5

We are a small startup using heavily jQuery. I'm commenting on this issue because a fix to this is essential for our business. I've included the fixes and it works now, but we don't want to have a custom jQuery source.

I hope this fix can make it in the next release.

Changed March 18, 2009 10:22PM UTC by brandon comment:6

owner: fleslerbrandon
status: assignednew

Changed March 18, 2009 10:22PM UTC by brandon comment:7

resolution: → duplicate
status: newclosed

Consolidating this into #4378