开发者

Uncaught ReferenceError: $ is not defined

I am t开发者_如何学Gorying to reference to jquery library to provide intellisense on another javascript file. But I got error such as "Uncaught ReferenceError: $ is not defined"

/// <reference path="jquery.min.js" />

$(document).ready(function () {
    alert("alert");
});

EDITED

Note: I have only one jquery library. Any other libraries have not been included.


Javascripts (including jQuery) are loaded with the following syntax:

<script type="text/javascript" src="url_to_your_script" />

Please review your HTML document to ensure that you have a line like that one, and that the src attribute points to the jQuery script's location. You can test it by copying the contents of the src attribute and pasting it in your browser's address bar.


As silly as it sounds, make sure that your script tags have a matching ending </script> tag. If you're missing one, it will mess up the loading of any scripts after it.


mine same problem solved by replacing

<script src="folderOnMyPc/local/jquery.js"> 

with

<script src="http://code.jquery.com/jquery-latest.min.js">  


You probably did not included jQuery properly, or use the noConflict mode : http://api.jquery.com/jQuery.noConflict/


You might use some other libraries that hide the $-function You can use jQuery as a substance to $. In your example:

/// <reference path="jquery.min.js" />

jQuery(document).ready(function () {
    alert("alert");
});

More info of using jQuery with other librarires can be found here.


All the .js files must be accessible by the server. Just check the ownership and permission of the file.


Try to get query from a CDN like,

For other CDNs http://jquery.com/download/

Note: make sure the url's have 'https://' prefix

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜