问题描述
在mvc3中提交表单后,如何使用ajax和jquery显示成功消息.我是MVC3的新手,以前从未使用过Ajax,因此我可以参考的任何一个电话解决方案或示例都可以使用...
how to show success message with ajax and jquery after submission of form in mvc3..
I am new in MVC3 and i never used ajax before so can any one tel me solution or example which i can refer...
推荐答案
function FUNCTIONNAME() {
br mode ="hold"/>
@using(Ajax.BeginForm("Sample",new AjaxOptions {UpdateTargetId ="targetId",HttpMethod ="Post"}))
{
br mode="hold" />
@using (Ajax.BeginForm("Sample", new AjaxOptions { UpdateTargetId = "targetId", HttpMethod = "Post"}))
{
}
它将在控制器中执行采样"操作,并将结果附加到"targetId" div
UpdateTargetId 属性指定了要在页面上显示或更新结果的位置.
\\控制器的东西
[httpPost]
公共字符串Sample()
{
返回"AjaxBeginForm调用的操作";
}
这样,您可以使用Ajax.BeginForm方法提交页面,而无需刷新整个页面.
}
it will "Sample" action in controller and append your result in "targetId" div
UpdateTargetId attribute specified where you want to display or update your result on page.
\\controller stuff
[httpPost]
public string Sample()
{
return "Action Called by AjaxBeginForm";
}
In this way you can submit you page by using Ajax.BeginForm method without refreshing your whole page.
这篇关于在mvc3中提交表单后,如何使用ajax和jquery显示成功消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!