test if jQuery library is loaded and the '$ is not defined' error
<p>in my .js file which will be using by external users I want to check if on their's page the jQuery lubrary is loaded. To do so, I'm using:</p>

<pre><code>if (!window.jQuery) {
    var script = document.createElement('script');
    script.type = "text/javascript";
    script.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js";
    document.getElementsByTagName('head')[0].appendChild(script);
}    

$(document).ready(function () {
    //do some jquery $.ajax({}); stuff
});
</code></pre>

<p>but, at the <code>$(document).ready(function () {</code> line I get the error message <code>ReferenceError: $ is not defined</code> How to fix it ?</p>

<h2>edit:</h2>

<p>I've added the line </p>

<pre><code>if (!window.jQuery) {
    ...
    document.getElementsByTagName('head')[0].appendChild("&lt;script type='text/javascript'&gt;$(document).ready(function () {...});&lt;/script&gt;");
} 
</code></pre>

<p>and now I get the <code>NS_ERROR_XPC_BAD_CONVERT_JS: Could not convert JavaScript argument arg 0 [nsIDOMHTMLHeadElement.appendChild]</code></p>
