'JQuery' is undefined

前端 未结 19 1407
生来不讨喜
生来不讨喜 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:01

    For me, this error typically occurs when there is a true Javascript error in some of my code. This prevents the jQuery.js file from being fully parsed. Look in the Error Console in Firebug, Safari or another debugging-friendly browser.

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

    Raja is right, URL.Content works.

    <script src="<%= Url.Content("~/Scripts/jquery-1.2.6.js")%>" type="text/javascript"></script>
    

    Further, to prevent yourself from getting surprised at the moment you are migrating your application to an IIS server, don't use web development server but use IIS when developing.

    You can use IIS directly from visual studio by editing the the web properties:

    • Go to the tab 'Web'
    • Check 'Use Local IIS Web server'
    • Click 'Create Virtual Directory'
    • Go to the IIS Manager to disable anonymous access in the created virtual directory if applicable.
    0 讨论(0)
  • 2020-12-28 16:04

    After Using the FIrebug, I found out the files were not found as the relative path for the files doesn;t work. TO resolve the problem, we should use the Url.Content Method to reslove the path. For example:

    <script src="<%= Url.Content("~/Scripts/jquery-1.2.6.js")%>" type="text/javascript"></script>
    
    0 讨论(0)
  • 2020-12-28 16:04

    This usually occurs when you have malformed HTML or JavaScript.

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

    try

    <script src="<%= ResolveUrl("~/Scripts/jquery-1.2.6.js")%>" type="text/javascript"></script>
    
    0 讨论(0)
  • 2020-12-28 16:07

    If all else fails, make sure the file has the right permissions set. This just happened to me!

    You can either right click the file in your directory and set the permission there, or just create another .js file in Visual Studio and copy and paste the contents over. Worked like a charm. :)

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