asp.net MVC 部分视图
我已经为加载事件创建了一个函数,如下所示:
$(function() {
$('#dvGames').load(
'<%= Url.Action("Partial3", "LiveGame") %>',{ gameDate: '2011-03-06' }
);
});
并且它有效。另外,我创建了一个日期更改函数,如下所示:
$(function() {
$('#datepicker').datepicker({
onSelect: function(dateText, inst) {
$.ajax({
type: "POST",
url: "/LiveGame/Partial3",
data: "gameDate=" + dateText,
success: function(result) {
alert(result);
var domElement = $(result); // create element from html
$("#dvGames").append(domElement); // append to end of list
}
});
}
});
});
但它不起作用。它也不参与控制器操作。我的控制器操作是:
public ActionResult Partial3(string gameDate)
{
return PartialView("Partial3");
}
请建议我解决此问题。
I have created a function for load event like this:
$(function() {
$('#dvGames').load(
'<%= Url.Action("Partial3", "LiveGame") %>',{ gameDate: '2011-03-06' }
);
});
and it works. Also, I have created a function for date change like this:
$(function() {
$('#datepicker').datepicker({
onSelect: function(dateText, inst) {
$.ajax({
type: "POST",
url: "/LiveGame/Partial3",
data: "gameDate=" + dateText,
success: function(result) {
alert(result);
var domElement = $(result); // create element from html
$("#dvGames").append(domElement); // append to end of list
}
});
}
});
});
but it doesnt work. neither it goes in controller action. My controller action is:
public ActionResult Partial3(string gameDate)
{
return PartialView("Partial3");
}
Please suggest me solution to this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有 2 个选项可以实现此目的
,或者
两者都不使用,第二个选项可能是使用 JSON 的最佳实践。
我不喜欢 MVC 帖子回调中的查询字符串,因为即使您不希望它们这样做,它们也会在帖子中持续存在。
2 options will work for this
or
don't use both and the 2nd is probably best practice use of JSON.
I don't like query strings in MVC post callbacks as they will persist across posts even if you don't want them to.