Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript not loaded correcly order?
    text
    copied!<p>I have a webpage where I load some javascript files in header. Some subpage will load aditional javascript files. On the main page everything is working just fine but on the subpage I get alot of exceptions like this : </p> <blockquote> <p>Uncaught TypeError: Property '$' of object [object Object] is not a function</p> </blockquote> <p>I can see that this exception occurs in details.js, voteHandler.js and 4 times in the HTML page itself. The exception is always thrown on this line : </p> <pre><code>$("document").ready(function () { </code></pre> <p>This is how the main page that works looks like : </p> <pre><code>&lt;head&gt; &lt;script type="text/javascript" src=/Scripts/jquery-1.7.1.min.js&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; //URL for voting var _postVoteUrl = 'http://localhost:5215/Post/Vote' //URL for tags var _tagsUrl = 'http://localhost:5215/Post/Tags' //Keep track of if a cascading is loading, if so, cancel submits var cascadingControlLoading = false; window.latestClick = ''; function IsNotDblClick(objectID) { if (window.latestClick != objectID &amp;&amp; !cascadingControlLoading) { window.latestClick = objectID; return true; } else { return false; } } $(document).ready(function () { if($('#rightCon').text().trim().length &lt; 1) {$('#rightCon').hide();} }); &lt;/script&gt; &lt;script type="text/javascript" src=/Scripts/jquery-ui-1.8.20.min.js&gt;"&gt;&lt;/script&gt; &lt;script type="text/javascript" src=/Scripts/jquery.elastic.source.js&gt;&lt;/script&gt; &lt;script type="text/javascript" src=/Scripts/jquery.validate.min.js&gt;&lt;/script&gt; &lt;script type="text/javascript" src=/Scripts/jquery.validate.unobtrusive.min.js&gt;&lt;/script&gt; &lt;script type="text/javascript" src=/Scripts/jquery.qtip.min.js&gt;&lt;/script&gt; &lt;script type="text/javascript" src=/Scripts/formhandler.js&gt;&lt;/script&gt; &lt;script type="text/javascript" src=/Scripts/taghandler.js&gt;&lt;/script&gt; &lt;script src="/Scripts/voteHandler.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src=/Scripts/select2.min.js %&gt;"&gt;&lt;/script&gt; &lt;script&gt; function TogglePostCon() { $('#postListEditorCon').toggle(); } SetupTagTextBox("txtTagBox", false); SetupTagTextBoxPersonalTag("txtPersonalTagBox", true); SetupTagTextBoxPersonalTag("txtPersonalIgnoreTagBox", true); &lt;/script&gt; &lt;script src="/Scripts/modernizr-2.5.3.js"&gt;&lt;/script&gt; &lt;/head&gt; </code></pre> <p>And this is the subpage that throws the exceptions : </p> <pre><code> &lt;head&gt; &lt;script type="text/javascript" src=/Scripts/jquery-1.7.1.min.js&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; //URL for voting var _postVoteUrl = 'http://localhost:5215/Post/Vote' //URL for tags var _tagsUrl = 'http://localhost:5215/Post/Tags' //Keep track of if a cascading is loading, if so, cancel submits var cascadingControlLoading = false; window.latestClick = ''; function IsNotDblClick(objectID) { if (window.latestClick != objectID &amp;&amp; !cascadingControlLoading) { window.latestClick = objectID; return true; } else { return false; } } $(document).ready(function () { if($('#rightCon').text().trim().length &lt; 1) {$('#rightCon').hide();} }); &lt;/script&gt; &lt;script type="text/javascript" src=/Scripts/jquery-ui-1.8.20.min.js&gt;"&gt;&lt;/script&gt; &lt;script type="text/javascript" src=/Scripts/jquery.elastic.source.js&gt;&lt;/script&gt; &lt;script type="text/javascript" src=/Scripts/jquery.validate.min.js&gt;&lt;/script&gt; &lt;script type="text/javascript" src=/Scripts/jquery.validate.unobtrusive.min.js&gt;&lt;/script&gt; &lt;script type="text/javascript" src=/Scripts/jquery.qtip.min.js&gt;&lt;/script&gt; &lt;script type="text/javascript" src=/Scripts/formhandler.js&gt;&lt;/script&gt; &lt;script type="text/javascript" src=/Scripts/taghandler.js&gt;&lt;/script&gt; &lt;script src="/Scripts/details.js"&gt;&lt;/script&gt; &lt;script src="/Scripts/voteHandler.js"&gt;&lt;/script&gt; &lt;script&gt; $(function () { //Google +1 $.getScript("http://apis.google.com/js/plusone.js", null, true); //Twitter $.getScript("http://platform.twitter.com/widgets.js", null, true); //Facebook $.getScript("http://connect.facebook.net/en_US/all.js#xfbml=1", function () { $('body').append('&lt;div id="fb-root"&gt;&lt;/div&gt;'); FB.init({ status: true, cookie: true, xfbml: true }); }, true); }); &lt;/script&gt; &lt;script src="/Scripts/modernizr-2.5.3.js"&gt;&lt;/script&gt; &lt;/head&gt; </code></pre> <p>I hade some of the scripts loaded at the bottom of the body before and this did not generate the exception but from what I read this is not a recomended way to go.</p> <p>So why is my subpage generating these exceptions?</p>
 

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