使用ajax.beginform ASP MVC视图中更新的div [英] Update div using ajax.beginform inside asp mvc view
问题描述
我要调用下面ajax.beginform后显示一个成功消息
从索引视图
I want to show a success message after calling the following ajax.beginform from Index view
@using (Ajax.BeginForm("Insert", "Home", new AjaxOptions() { UpdateTargetId = "result", HttpMethod = "POST" }))
{
@Html.TextAreaFor(m => m.openion)
}
这是我的结果的div
this is my result div
<div id="result">
</div>
和我的控制器是
[Httppost]
public ActionResult InforMessage(openionModel usr)
{
return Content("Thanks for adding your openion");
}
但是当我尝试这一点,是要另一种观点InforMessage
它没有更新的结果股利。
没有Informessage存在。它仍然打开带有信息的新页面
感谢您的加入openion。如何解决这个问题?
but when i try this it is going to another view InforMessage It is not updating the result div. There is no Informessage Exist. Still it open a new page with message "Thanks for adding your openion".How to solve this?
推荐答案
如果您重定向到另一个页面的,因为你没有加载正确的脚本(或有重复或让他们以错误的顺序),所以它做一个正常的提交。
If your redirecting to another page its because you do not have the correct scripts loaded (or have duplicates or have them in the wrong order) so its doing a normal submit.
确保已包括(按顺序)
jquery-{version}.js
jquery.unobtrusive-ajax.js
这篇关于使用ajax.beginform ASP MVC视图中更新的div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!