我可以使用ajax调用将数据发送到多个页面吗?我不想为此使用另一个ajax调用。
样本代码:
$.ajax({
type: 'POST',
url: '../services/form_data.php', //can I send data to multiple url with same ajax call.
data: {
answer_service: answer,
expertise_service: expertise,
email_service: email,
},
success: function (data) {
$(".error_msg").text(data);
}
});发布于 2013-08-07 08:01:04
对于来自多个页面的1个请求,您不能使用相同的代码。
但是你可以发送两个请求。它可以通过复制粘贴ajax代码或构建一个获取URL并使用此URL发送请求的函数来实现。
function sendMyAjax(URL_address){
$.ajax({
type: 'POST',
url: URL_address,
data: {
answer_service: answer,
expertise_service: expertise,
email_service: email,
},
success: function (data) {
$(".error_msg").text(data);
}
});
};https://stackoverflow.com/questions/18097747
复制相似问题