AJAX表单中的Ajax表单 [英] Ajax form within ajax form
问题描述
问题标题可能会出现奇怪,但它的要求。
The question title might appear strange but it is requirement.
方案 - 我有Ajax表单(MVC4)一个按钮。让我们来命名形式的的MainForm 的。此按钮将打开弹出式窗口,这个弹出也有称为Ajax表单(MVC4)的 childForm 的
Scenario - I have ajax form (MVC4) with a button. Let's name the form as mainForm. This button opens popup and this popup also have ajax form (MVC4) named as childForm.
的 code的片段MainForm的的
@using (Ajax.BeginForm("UserPost", "Admin", null, ajaxOptions, new { @id = "frmUser" }))
{
... Code for opening popup
}
的 code的片段childForm 的
@using (Ajax.BeginForm("SendReminder","Admin",null, ajaxOptions,new { @id = "frmPop" }))
{
...Button code
}
问题 - 当我点击弹出窗口中childForm任何按钮,为MainForm中的方法被执行
Problem - When I click any button in childForm in Popup, the method for mainForm gets executed.
我在寻找如何引导按钮点击为childForm执行方法只?
I am looking for how to guide button click to execute method for childForm only?
推荐答案
不要在你的脚本中使用ajax的形式,但只是一个Ajax调用
don't use an ajax form but just an ajax call in your script
$('.btnSubmit').on('click', function(){
$.ajax({
url: '@Url.Action("UserPost", "Admin")',
type: 'post',
cache: false,
async: true,
data: { id: "frmUser" },
success: function(result){
// do something if you want like alert('successful!');
}
});
});
这篇关于AJAX表单中的Ajax表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!