admin管理员组文章数量:1291660
I'm using ASP.NET MVC 4 and I'm trying to pass a value from my JavaScript to my Controller Action. Here's what I'm trying to do in my JavaScript :
function DoubleClick() {
debugger;
var id = 1;
$.ajax({
type: "POST",
url: "/Home/GetAppId",
data: { id: id}
});
}
And my action (really simple action) :
public JsonResult GetAppId(int id)
{
//some code will be included here
}
In my layout template, I'm including correctly my scripts (actually I'm using JS in some ohter pages and it works) :
<title>@ViewBag.Title</title>
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery.validate.globalize.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.js")" type="text/javascript"></script>
<link href="@Url.Content("~/Content/jquery-ui-1.10.4.custom.min.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-ui-1.10.4.custom.min.js")" type="text/javascript"></script>
<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.ui.core.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.ui.datepicker.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/DatePickerReady.js")" type="text/javascript"></script>
When I'm opening the Chrome dev tool (F12), I'm seeing the following error message in the console tab :
Uncaught ReferenceError: jQuery is not defined
I can't really see where the problem is. Any idea?
I'm using ASP.NET MVC 4 and I'm trying to pass a value from my JavaScript to my Controller Action. Here's what I'm trying to do in my JavaScript :
function DoubleClick() {
debugger;
var id = 1;
$.ajax({
type: "POST",
url: "/Home/GetAppId",
data: { id: id}
});
}
And my action (really simple action) :
public JsonResult GetAppId(int id)
{
//some code will be included here
}
In my layout template, I'm including correctly my scripts (actually I'm using JS in some ohter pages and it works) :
<title>@ViewBag.Title</title>
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery.validate.globalize.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.js")" type="text/javascript"></script>
<link href="@Url.Content("~/Content/jquery-ui-1.10.4.custom.min.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-ui-1.10.4.custom.min.js")" type="text/javascript"></script>
<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.ui.core.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.ui.datepicker.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/DatePickerReady.js")" type="text/javascript"></script>
When I'm opening the Chrome dev tool (F12), I'm seeing the following error message in the console tab :
Uncaught ReferenceError: jQuery is not defined
I can't really see where the problem is. Any idea?
Share Improve this question asked Mar 10, 2015 at 8:47 TraffyTraffy 2,86115 gold badges54 silver badges80 bronze badges1 Answer
Reset to default 6jQuery.Validate uses jQuery.
<script src="@Url.Content("~/Scripts/jquery.validate.globalize.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.js")" type="text/javascript"></script>
Should be like this:
<script src="@Url.Content("~/Scripts/jquery.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.globalize.min.js")" type="text/javascript"></script>
As to why your JavaScript is not posting back the Value that is another error.
In Ajax you using "POST". Put a HttpPost Attribute on your method.
[HttpPost]
public JsonResult GetAppId(int id)
{
//some code will be included here
}
本文标签:
版权声明:本文标题:javascript - ASP.NET MVC - Uncaught ReferenceError: jQuery is not defined even if I'm including the library - Stack Over 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741535239a2383988.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论