Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok, so it turns out that the default implementation of the <code>$.getScript()</code> function works differently depending on whether the referenced script file is on the same domain or not. External references such as:</p> <pre><code>$.getScript("http://www.someothersite.com/script.js") </code></pre> <p>will cause jQuery to create an external script reference, which can be debugged with no problems.</p> <pre><code>&lt;script type="text/javascript" src="http://www.someothersite.com/script.js"&gt;&lt;/script&gt; </code></pre> <p>However, if you reference a local script file such as any of the following:</p> <pre><code>$.getScript("http://www.mysite.com/script.js") $.getScript("script.js") $.getScript("/Scripts/script.js"); </code></pre> <p>then jQuery will download the script content asynchronously and then add it as inline content:</p> <pre><code>&lt;script type="text/javascript"&gt;{your script here}&lt;/script&gt; </code></pre> <p>This latter approach does <em>not</em> work with any debugger that I tested (Visual Studio.net, Firebug, IE8 Debugger).</p> <p>The workaround is to override the <code>$.getScript()</code> function so that it always creates an external reference rather than inline content. Here is the script to do that. I have tested this in Firefox, Opera, Safari, and IE 8.</p> <pre><code>&lt;script type="text/javascript"&gt; // Replace the normal jQuery getScript function with one that supports // debugging and which references the script files as external resources // rather than inline. jQuery.extend({ getScript: function(url, callback) { var head = document.getElementsByTagName("head")[0]; var script = document.createElement("script"); script.src = url; // Handle Script loading { var done = false; // Attach handlers for all browsers script.onload = script.onreadystatechange = function(){ if ( !done &amp;&amp; (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") ) { done = true; if (callback) callback(); // Handle memory leak in IE script.onload = script.onreadystatechange = null; } }; } head.appendChild(script); // We handle everything using the script element injection return undefined; }, }); &lt;/script&gt; </code></pre>
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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