Note that there are some explanatory texts on larger screens.

plurals
  1. POIE9 - SCRIPT5009: "jQuery" is undefined
    primarykey
    data
    text
    <p>the following code runs into the error <em>SCRIPT5009: "jQuery" is undefined</em> in IE9 (maybe also in older IE versions):</p> <pre><code>var $tx; if (window.jQuery) { $tx = jQuery; if( jQuery().jquery.replace(".", "") &lt; 17.1 ) { addjQuery(); } } else { addjQuery(); } function addjQuery() { document.write('&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;&lt;\/script&gt;'); document.write('&lt;script type="text/javascript"&gt;$tx = jQuery.noConflict();&lt;\/script&gt;'); } document.write('&lt;script src="workingScript.js"&gt;&lt;\/script&gt;'); </code></pre> <p>I solved it! It's working fine this way:</p> <pre><code>var $tx; if (window.jQuery) { $tx = jQuery; if( jQuery().jquery.replace(".", "") &lt; 17.1 ) { addjQuery(); } } else { addjQuery(); } function addjQuery() { loadScript("http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js", function(){ $tx = jQuery.noConflict(true); }); } document.write('&lt;script src="workingScript.js"&gt;&lt;\/script&gt;'); function loadScript(url, callback){ var script = document.createElement("script") script.type = "text/javascript"; if (script.readyState){ //IE script.onreadystatechange = function(){ if (script.readyState == "loaded" || script.readyState == "complete"){ script.onreadystatechange = null; callback(); } }; } else { //Others script.onload = function(){ callback(); }; } script.src = url; document.getElementsByTagName("head")[0].appendChild(script); } </code></pre> <p>workingScript.js:</p> <pre><code>(function ($) { // some code here })($tx); </code></pre> <p>The error occours here <em>"$tx = jQuery.noConflict();"</em> if <code>addjQuery</code> function is called. If the website already uses the current jQuery version, erverythings works fine.</p> <p>Does anyone have an idea how to solve this?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload