From: John Resig Date: Sun, 9 Sep 2007 18:09:27 +0000 (+0000) Subject: Errors were occuring with getScript, if you called it too early. X-Git-Url: http://git.asbjorn.it/?a=commitdiff_plain;h=4e504d86b9dc9e1501f598744f6c3b19f834c487;hp=97fe63cb4826cbeb74bc0c3a72648f57ae0f0881;p=jquery.git Errors were occuring with getScript, if you called it too early. --- diff --git a/src/ajax.js b/src/ajax.js index ffe3048..ef95048 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -214,6 +214,7 @@ jQuery.extend({ // If we're requesting a remote document // and trying to load JSON or Script if ( !s.url.indexOf("http") && s.dataType == "script" ) { + var head = document.getElementsByTagName("head")[0]; var script = document.createElement("script"); script.src = s.url; @@ -228,12 +229,12 @@ jQuery.extend({ done = true; success(); complete(); - document.body.removeChild( script ); + head.removeChild( script ); } }; } - document.body.appendChild(script); + head.appendChild(script); // We handle everything using the script element injection return;