简体   繁体   English

使用Ajax和jQuery Modal提交表单

[英]Submit form with Ajax and jQuery Modal

How to Submit form with Ajax and jQuery Modal jQuery Modal Site . 如何使用Ajax和jQuery Modal提交表单jQuery Modal Site Here my ajax: 这是我的ajax:

$('#save').submit(function(event) {
    event.preventDefault();
    $.ajax({ 
        data: $(this).serializeArray(), 
        type: $(this).attr('method'), 
        url: $(this).attr('action'), 
        success: function() { 
            $('#message').html("Success").modal();
        }
    });
    return false;
});

You just have to mention the form ID with serialize function and it will work..It doesn't matter that your form is in modal dialog or on page.. Yes but if you are opening form in Iframe than You've to use different method. 您只需要提及带有序列化功能的表单ID,它就可以使用。.您的表单在模式对话框中还是在页面上都没有关系。是的,但是如果您要在Iframe中打开表单,则必须使用其他表单方法。

use this line with data attribute. 将此行与data属性一起使用。

$("#formId").serialize(); $(“#formId”)。serialize();

$('#save').submit(function(event) {
    event.preventDefault();
    $.ajax({ 
        data: $("#formId").serialize(), 
        type: $(this).attr('method'), 
        url: $(this).attr('action'), 
        success: function() { 
            $('#message').html("Success").modal();
        }
    });
    return false;
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM