Updated JQuery - get Microsoft JScript runtime err

2019-06-24 07:59发布

问题:

All was good until I updated Jquery and now I get get Microsoft JScript runtime error: 'jQuery' is undefined in jquery.validate.min.js- I am at a loss as to what to do.

MVC3 - using Telerik extensions controls - used nuget

_Layout.cshtml (valid paths)

I have tried both script and link tags:

<link href="@Url.Content("~/Scripts/jquery.validate.min.js")" rel="stylesheet" />
<link href="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" rel="stylesheet" />
<link href="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" rel="stylesheet" />

And I tried

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" type="text/javascript"></script>

Also added to jQuery(false) to scriptregistrar tag

Packages.config

<package id="jQuery" version="1.7.1" />
<package id="jQuery.UI.Combined" version="1.8.17" />
<package id="jQuery.Validation" version="1.9" />

Visual Studio 2010 - running in IE9. Any advice greatly appreciated!

回答1:

Load jquery-1.7.1.min.js before the jquery.validate plugins. And use <script>, not <link>.

<script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobstrusive.min.js")"></script>