'JQuery' is undefined

前端 未结 19 1401
生来不讨喜
生来不讨喜 2020-12-28 15:21

I am working on a ASP.net project created with local file system settings. I am using MVC and Jquery. Jquery is working fine when I run the application in debug mode i.e. in

相关标签:
19条回答
  • 2020-12-28 16:08

    I got the message by having a mismatch between the version of JavaScript in the page and the version in the project.

    On the page: <script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>

    Actual version in the project: jquery-1.4.1.min.js

    Diagnosed by using Firebug, and setting it show all errors, as described in the accepted answer.

    0 讨论(0)
  • 2020-12-28 16:09

    Common mistakes is that other Jquery Scripts are included first(Jquery.validation.js) before the Jquery.js

    0 讨论(0)
  • 2020-12-28 16:11

    One additional reason for this error I found out occurs if you are loading jQuery from a cdn and a local script from your server. They load independently, so if the local script finishing before the jQuery it will also be executed before, which gives us the lovely error. This is especialy an issue if jQuery is not in the browsercache so you might see this error occur on the first time the scripts loads and vanish later.

    0 讨论(0)
  • 2020-12-28 16:12

    You could also try letting Google host jQuery for you:

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
    

    This will avoid having to worry about the relative path to the script, avoid load on your server, and will be faster for users (who probably already have it in their browser's cache somewhere).

    0 讨论(0)
  • 2020-12-28 16:14

    Try using Firebug 'Net' tab to see if the file gets loaded.

    You can also configure Firebug to fail on all errors and see when the error happens as compared to when jQuery gets loaded.

    0 讨论(0)
  • 2020-12-28 16:14

    Jquery?!
    You mean jQuery?

    Javascript is case-sensitive. Jquery is not the same as jQuery.

    0 讨论(0)
提交回复
热议问题