多个URL在同一个Ajax调用?这可能吗? [英] Multiple url in same ajax call?is this possible?
本文介绍了多个URL在同一个Ajax调用?这可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以送我的数据使用Ajax调用多个页面? 我不希望使用其他AJAX调用这一点。
样品code:
$。阿贾克斯({
键入:POST,
网址:../services/form_data.php',//我可以将数据发送到多个URL以相同的AJAX调用。
数据: {
answer_service:答案,
expertise_service:专业知识,
email_service:电子邮件,
},
成功:功能(数据){
$(。ERROR_MSG)文本(数据);
}
});
解决方案
您不能使用相同的code从多页1的要求。
但你可以发送2请求。它可以通过复制来完成粘贴阿贾克斯code或建立一个函数来获取URL并发送请求,该网址
函数sendMyAjax(URL_address){
$阿贾克斯({
键入:POST,
网址:URL_address,
数据: {
answer_service:答案,
expertise_service:专业知识,
email_service:电子邮件,
},
成功:功能(数据){
$(。ERROR_MSG)文本(数据);
}
});
};
Can I send my data to multiple pages using ajax call? I dont want to use another ajax call for this.
Sample code:
$.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);
}
});
解决方案
You can't use the same code for 1 request from many pages.
BUT you can send 2 requests. its can be done by copy paste your ajax code or by build a function that gets URL and send request with this 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);
}
});
};
这篇关于多个URL在同一个Ajax调用?这可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文