2014-05-11 157 views
0

如何使用Ajax和jQuery模块提交表单jQuery Modal Site。在这里我的ajax:使用Ajax和jQuery提交表单Modal

$('#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; 
}); 

回答

0

你一定要提到与序列化功能的形式ID,它会work..It不要紧,你的形式是模态对话框或页面..是的,但如果你是在Iframe中打开表单比你必须使用不同的方法。

使用此行与数据属性。 ()“#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; 
});