Javascript Jquery ajax在HTTPs上调用延迟响应
我有两个环境,Dev和QA,Dev没有HTTP,QA有HTTPS,我的代码从Google导入联系人。我打了一个ajax电话来获取联系人, 问题是,在Dev中,它工作正常,但在QA中,它只是在导入时停止浏览器(尽管导入在后端运行,数据保存在数据库中) 我在控制台上没有得到任何信息,在Chrome的网络选项卡中,我看到没有收到响应 这是我的片段的一部分Javascript Jquery ajax在HTTPs上调用延迟响应,javascript,jquery,ajax,asynchronous,https,Javascript,Jquery,Ajax,Asynchronous,Https,我有两个环境,Dev和QA,Dev没有HTTP,QA有HTTPS,我的代码从Google导入联系人。我打了一个ajax电话来获取联系人, 问题是,在Dev中,它工作正常,但在QA中,它只是在导入时停止浏览器(尽管导入在后端运行,数据保存在数据库中) 我在控制台上没有得到任何信息,在Chrome的网络选项卡中,我看到没有收到响应 这是我的片段的一部分 $.ajax({ type: "GET", url :"index.
$.ajax({
type: "GET",
url :"index.php?page=AJAX&action=importSocial",
data: {'import':importSource},
success: function(output) {
if(output=='multiple'){
}else if(output.indexOf("getFB") >0){
window.location = output;
//alert(output+output.length);
}else{
window.location = window.location.href;
}
}
});
async默认为true,所以我没有碰它,有没有人可以在这方面帮助我,我想这是因为HTTPS
Async和javascript在这里是基本的标记,Gmail API与之无关,附标签编辑器
- 浏览器使用正确的JSON负载生成了一个成功的HTTP请求(与Chrome(浏览器)网络面板交叉引用)
(请参阅)查看上面编写的jQuery
调用应该是什么样子$.ajax()
- 确保相同的成功HTTP请求以浏览器生成的方式离开计算机
- 从服务器到达客户端的任何类型的响应
- 任何到达服务器的HTTP请求
- 成功的HTTP请求到达您的服务器
- 您的服务器端代码正在运行吗
- 检查你的日志
- 数据库里有什么
- 您的PHP代码是否允许对GMail的请求
- 使用Fiddler查看客户端(您的PHP代码)和服务器(GMail API)在服务器端的
API调用中发生了什么联系人
- 从服务器生成的HTTP响应是什么样子的
- 从服务器到达客户端PC时是否生成了成功的HTTP响应
您是否可以添加
complete
/failure
回调,正如其他答案所建议的那样(这应该会准确地告诉您发生了什么):
$.ajax({
键入:“获取”,
url:“index.php?page=AJAX&action=importSocial”,
数据:{'import':importSource},
成功:功能(输出){
如果(输出=='multiple'){
//没什么?这就是你想在这里做的吗?
}
否则{
if(output.indexOf(“getFB”)>0){
window.location=输出;
//警报(输出+输出.长度);
}
否则{
window.location=window.location.href;
}
}//结束:如果(输出=='multiple')
},//结束:`success`:
/*************************************************
*以下假设jquery1.4.x
*------------------------------------------------
*jQuery 1.4.x`failure`回调函数(3个参数)
*jqXHR:jquery1.4.x,XMLHttpRequest)对象
*字符串文本状态:
*null:如果$.ajax()请求成功,则实际为null(不是字符串)
*“超时”
*“错误”
*“中止”
*“解析器错误”
*
*字符串错误抛出:来自服务器的HTTP错误
*************************************************/
失败:函数(jqXHR、textStatus、errorshown){
如果(!textStatus){
console.err(
“问题:”+
“$.ajax()`failure`调用的回调:”+
“`textStatus`=`null`或*空字符串*:”+
“显然没有发生$.ajax()请求错误?”
);//结束:console.err()
}//结束:如果
否则{
console.err(
“$.ajax`failure`type\”(0)\”“+
“\n”+
“`HTTP Status`来自服务器:(1)”+
“\n”+
“`jqXHR对象:(2)”,
textStatus,//第一次替换(0)-字符串:$.ajax()状态代码
ErrorRown,//第二次替换(1)-字符串:HTTP状态代码
jqXHR//3次替换(2)-对象:jqXHR对象
);//结束:console.err()
}//结束:其他
},//结束:“失败”:
/*************************************************
*以下假设jquery1.4.x
*------------------------------------------------
*
*jQuery 1.4.x`complete`回调函数(2个参数)。
*此函数在请求完成时调用,即。
*在执行'success'和'error'回调之后。
*
*jqXHR:jquery1.4.x,XMLHttpRequest)对象
*字符串文本状态:
*“成功”
*“未修改”
*“无内容”
*“错误”
*“超时”
*“中止”
*“解析器错误”
*
*************************************************/
完成:函数(jqXHR jqXHR,字符串textStatus){
如果(!textStatus){
console.err(
“问题:”+
“$.ajax()`complete`调用的回调:”+
“`textStatus`=`null`或*空字符串*:”+
“显然,$.ajax()请求没有完成?”
);//结束:console.err()
}//结束:如果
否则{
console.err(
“$.ajax`complete`类型:\”“(0)\”“+
“\n”+
“`jqXHR对象:(1)”,
textStatus,//第一次替换(0)-字符串:$.ajax()状态代码
jqXHR//第二次替换(1)-对象:jqXHR对象
);//结束:console.err()
}//结束:其他
},//结束:“完成”
}); //结束:$.ajax()
Cross-domain limition?@DevlshOne感谢您的帮助,但这不是问题,c上没有任何报告
$.ajax({
type: "GET",
url :"index.php?page=AJAX&action=importSocial",
data: {'import':importSource},
success: function(output) {
if(output=='multiple'){
//NOTHING?? IS THAT WHAT YOU MEANT TO DO HERE?
}
else{
if(output.indexOf("getFB") >0){
window.location = output;
//alert(output+output.length);
}
else{
window.location = window.location.href;
}
} //END: if(output=='multiple')
}, //END: `success`:
/*************************************************
* The following assumes jQuery 1.4.x
*------------------------------------------------
* <SUMMARY> jQuery 1.4.x `failure` callback function (3 params)</SUMMARY>
* <PARAM> jqXHR jqXHR: jQuery 1.4.x, XMLHttpRequest) object </PARAM>
* <PARAM> String textStatus:
* <VALUE> null: actual null (not a string) if $.ajax() request is successful)</VALUE>
* <VALUE> "timeout"</VALUE>
* <VALUE> "error"</VALUE>
* <VALUE> "abort"</VALUE>
* <VALUE> "parsererror"</VALUE>
* </PARAM>
* <PARAM> String errorThrown: HTTP error from Server</PARAM>
*************************************************/
failure: function(jqXHR, textStatus, errorThrown){
if(!textStatus){
console.err(
"PROBLEM: " +
"$.ajax() `failure` callback called: " +
"`textStatus` = `null` or *empty string*: " +
"apparently no $.ajax() request error occurred?"
); //END: console.err()
} //END: if
else {
console.err(
"$.ajax `failure` type \"(0)\"" +
"\n" +
"`HTTP Status` from Server: (1)" +
"\n" +
"`jqXHR object: (2)",
textStatus, // 1st replacement (0) - String: $.ajax() status code
errorThrown, // 2nd replacement (1) - String: HTTP status code
jqXHR // 3rd replacement (2) - object: jqXHR object
); //END: console.err()
} //END: else
}, //END: 'failure`:
/*************************************************
* The following assumes jQuery 1.4.x
*------------------------------------------------
* <SUMMARY>
* jQuery 1.4.x `complete` callback function (2 params).
* This function is called when the request finishes, i.e.
* after the `success` and `error` callbacks are executed.
* </SUMMARY>
* <PARAM> jqXHR jqXHR: jQuery 1.4.x, XMLHttpRequest) object </PARAM>
* <PARAM> String textStatus:
* <VALUE> "success" </VALUE>
* <VALUE> "notmodified" </VALUE>
* <VALUE> "nocontent" </VALUE>
* <VALUE> "error" </VALUE>
* <VALUE> "timeout" </VALUE>
* <VALUE> "abort" </VALUE>
* <VALUE> "parsererror" </VALUE>
* </PARAM>
*************************************************/
complete: function(jqXHR jqXHR, String textStatus ){
if(!textStatus){
console.err(
"PROBLEM: " +
"$.ajax() `complete` callback called: " +
"`textStatus` = `null` or *empty string*: " +
"apparently $.ajax() request didn't complete?"
); //END: console.err()
} //END: if
else {
console.err(
"$.ajax `complete` type: \"(0)\"" +
"\n" +
"`jqXHR object: (1)",
textStatus, // 1st replacement (0) - String: $.ajax() status code
jqXHR // 2nd replacement (1) - object: jqXHR object
); //END: console.err()
} //END: else
}, //END: 'complete'
}); //END: $.ajax()