【发布时间】:2013-05-19 21:28:33
【问题描述】:
Ajax 不工作,我已经通过添加输入按钮进行了测试,它可以工作,但它不适用于 ActionLink。我在我的 cshtml 上添加了 jQuery 包。我正在使用最新的 jQuery 版本 2.0。
这是我的代码:
查看:
<span> @Ajax.ActionLink(
"Name Ajax",
"ShowUser",
new
{
id = 1,
sort = "FullName"
},
new AjaxOptions
{
HttpMethod = "POST",
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "userGridDiv",
OnBegin = "myonbegin",
OnSuccess = "myonsuccess",
OnComplete = "myoncomplete",
OnFailure = "myonfailure"
},
new
{
@class = "grid-link",
}
)
/span>
@section scripts{
<script type="text/javascript">
$(document).ready(function () {
$("#animatedgif").hide();
});
function myonbegin() {
//show animated gif
alert("helloworld");
$("#animatedgif").show();
}
function myonsuccess() {
//disable animated gif
$("#animatedgif").hide();
}
function myonfailure() {
//disbale animated gif
$("#animatedgif").hide();
}
function myoncomplete() {
//disable animated gif
$("#animatedgif").hide();
}
</script>
}
控制器:
public ViewResult ShowUser(int id, string sort)
{
User obj = new User();
var model = obj.GetUsers(id, sort);
View("userView", model);
}
【问题讨论】:
标签: jquery c#-4.0 asp.net-mvc-4