提交后,为什么Ajax.BeginForm重定向到新的空白页? [英] Why Ajax.BeginForm redirect to new empty page after submission?
本文介绍了提交后,为什么Ajax.BeginForm重定向到新的空白页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么Ajax.BeginForm在提交后将我的页面重定向到新的空白页面?
Why Ajax.BeginForm redirect my page to new empty page after submission?
我的控制器代码是:
[HttpPost]
public void ProductCommentAdd(int productId, string text)
{
//Do something
}
视图中的Mvc ajax调用是:
Mvc ajax call in view is:
@using (Ajax.BeginForm("ProductCommentAdd", "Shop", new AjaxOptions() { HttpMethod = "POST"}))
{
<input type="hidden" value="@Model.ProductId" name="ProductId"/>
<textarea name="text"></textarea>
<input type="submit" value="Submit"
}
当我单击提交按钮时,我的页面将重定向到新的空白页面.我该如何解决?
When I click submit button my page redirect to new empty page. How I can fix it?
推荐答案
您需要在页面中包含以下脚本:
you need to include the following script to your page:
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")"
type="text/javascript"></script>
这篇关于提交后,为什么Ajax.BeginForm重定向到新的空白页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文