由于某些原因,我需要传输一个表单到2个不同的脚本在同一时间。你知道我该怎么做吗?任何帮助都将不胜感激。
jQuery("#form1").validate({
debug: true,
submitHandler: function() {
var dataString = jQuery("#order_form form").serialize();
jQuery.ajax({
type: "POST",
url: "checkout.php",
data: dataString,
//dataType: text,
success: function(msg) {
jQuery('#order').animate({ left: '400px'}, 4000, 'linear').fadeOut(2500);
jQuery('#form1').animate({ left: '400px'}, 0, 'linear').fadeOut(0);
//jQuery('#left').css('left', '400px');
jQuery('#order_form').html("<div style='margin-top:117px; text-align:center;' id='message'></div>");
jQuery('#message').html("<p class='text'>Thank you</p>")
.append("<p class='text' style='margin-bottom:15px;'></p>")
.fadeIn(500, function() {
jQuery('#message').append("<img id='checkmark' src='form/ok.png' >");
});
},
});
return false;
}
}); 发布于 2015-03-17 19:11:51
是的,您可以通过为第二个页面添加另一个ajax代码,
submitHandler: function() {
$.ajax();// first
$.ajax();// second
}发布于 2015-03-17 20:18:31
非常感谢你的快速回复。这样,就在第一个后面(对不起,我是新手)?
**jQuery.ajax({
type: "POST",
url: "checkout.php",
data: dataString,
//dataType: text,
success: function(msg) {**
jQuery('#order').animate({ left: '400px'}, 4000, 'linear').fadeOut(2500);
jQuery('#form1').animate({ left: '400px'}, 0, 'linear').fadeOut(0);
//jQuery('#left').css('left', '400px');
jQuery('#order_form').html("<div style='margin-top:117px; text-align:center;' id='message'></div>");
jQuery('#message').html("<p class='text'>Thank you</p>")
.append("<p class='text' style='margin-bottom:15px;'></p>")
.fadeIn(500, function() {
jQuery('#message').append("<img id='checkmark' src='form/ok.png' >");
});
},
**jQuery.ajax({
type: "POST",
url: "checkout2.php",
data: dataString,
//dataType: text,
});
},https://stackoverflow.com/questions/29097482
复制相似问题