Loading a javascript file dynamically is not working
<p>I have the following piece of code that is suppose to include a javascript file dynamically however it fails to do so: </p>

<pre><code>&lt;script&gt;
function AddScript(url, callback) {
    var script   = document.createElement('script');
    script.src   = url;
    script.type  = 'text/javascript';
    script.defer = false;

    if (typeof callback != "undefined" &amp;&amp; callback != null) {

        // IE only, connect to event, which fires when JavaScript is loaded
        script.onreadystatechange = function() {
            if (this.readyState == 'complete' || this.readyState == 'loaded') {
                this.onreadystatechange = this.onload = null; // prevent duplicate calls
                callback();
            }
        }

        // FireFox and others, connect to event, which fires when JavaScript is loaded
        script.onload = function() {
            this.onreadystatechange = this.onload = null; // prevent duplicate calls
            callback();
        };
    }

    var head = document.getElementsByTagName('head').item(0);
    head.appendChild(script);
}
        var adParams = {
  a: "7462284", numOfTimes: "9",duration: "1",period: "Minute"
};
AddScript("http://cdn.adk2.com/adstract/scripts/popunder/popunder.js",
    function() {

    });
&lt;/script&gt;
</code></pre>

<p>the code is suppose to load a popunder but when its executed nothing happens and it fails to open the js URL.</p>

<p>What is wrong with the code?</p>
