jQuery.noConflict() vs Ajax : variable scope limited?
<p>This is my code that load (if not present) jquery library : </p>

<pre><code>(function () {
    var pathWidget = "http://www.mywebsite.com";
    var jQuery;

    if (window.jQuery === undefined) {
        var script_tag = document.createElement('script');
        script_tag.setAttribute("type", "text/javascript");
        script_tag.setAttribute("src", pathWidget + "/scripts/jquery-1.7.2.min.js");

        if (script_tag.readyState) {
            script_tag.onreadystatechange = function () {
                if (this.readyState == 'complete' || this.readyState == 'loaded') {
                    scriptLoadHandler();
                }
            };
        } else {
            script_tag.onload = scriptLoadHandler;
        }

        (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);
    } else {
        jQuery = window.jQuery;
        mainWidget();
    }

    function scriptLoadHandler() {
        jQuery = window.jQuery.noConflict(true);
        mainWidget();
    }

    function mainWidget() {
        jQuery(document).ready(function ($) {
            var widget_url = pathWidget + "/widget/widget.aspx?&amp;callback=?"
            $.getJSON(widget_url, function (data) {
                $('#container').html(data.htmlWidget);
            });
        });
    }
})();
</code></pre>

<p>This is the code loaded trought ajax/jsonp :</p>

<pre><code>&lt;div id="exDiv"&gt;First&lt;/div&gt;

&lt;script type="text/javascript"&gt;
    $('#exDiv').html("Second");   
&lt;/script&gt; 
</code></pre>

<p>The problem is : if the host page doesnt have jquery, when the aspx code try to execute <code>$('#exDiv')</code>, it "crash", and I get <code>$ is not a function</code>. Seems that after the ajax call the <code>$</code> setted as no-conflict variable is vanished.</p>

<p>How can I resolve this trouble?</p>
