我想让这个功能通用,基于按钮id。它目前在一个div上(在某种程度上)可以工作,但在页面上有多个div中的多个表单。敬请指教...
var frm_submit_event = function(e) {
var $this = $(this); // the button
var frm = $('#' + selected_form_div + " form");
console.log(frm);
console.log(frm.serialize());
e.preventDefault();
$.ajax({
type: "POST",
url: "classes/forms/ajaxPost.php",
data: frm.serialize(),
dataType: "text",
success: function($result) {
//var obj = jQuery.parseJSON(data); if the dataType is not specified as json uncomment this
$('#' + selected_form_div).html($result);
},
error: function() {
alert('error handing here');
}
});
}
$(document).on("click", '.frm_submit_btn', frm_submit_event);不知道下一步该怎么走...
发布于 2016-12-22 09:43:15
使用switch语句,检查按钮id。在每种情况下,从按钮的受尊重的表单中获取/构建数据,然后将数据传递给ajax调用以进行发布。
https://stackoverflow.com/questions/41274567
复制相似问题