mis*_*hap 5 javascript asp.net-mvc jquery posting
我在StackOverflow上有类似的帖子,但也许我的误解更为重要.我有一个动作索引()和索引视图的渲染.从Index()视图取决于单击的按钮[HttpPost]索引()或[HttpPost] Search()必须被调用因为我发布了一些数据.发布到不同操作的唯一方法是使用jQuery吗?如果jQuery是唯一的方法,如果我的操作返回视图(完整的Html页面),我必须从$ .post清理整个文档元素并用我的视图html填充它?我对这一切都很陌生,非常感谢!
@using (Html.BeginForm())
{
<input name="startDate" type="text" size="20" class="inputfield" id="datepicker" />
<a href="#" id="apply_button">...</a>
<a href="#" id="go_button">...</a>
}
public ActionResult Index(string lang)
{
return View();
}
//Perhaps this action is needed
[HttpPost]
public ActionResult Index(string lang, string startDate)
{
return View();
}
[HttpPost]
public ActionResult Search(string lang, string startDate)
{
return View();
]
Run Code Online (Sandbox Code Playgroud)
MJ *_*son 14
您可以根据单击的按钮更改表单的操作属性.
例如,当点击"go"按钮时,要发布到"搜索"操作:
$('#go_button').click(function() {
$('form').attr("action", "Search"); //change the form action
$('form').submit(); // submit the form
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4179 次 |
| 最近记录: |