【发布时间】:2014-12-02 10:28:38
【问题描述】:
Ajax 不仅仅在 iPad 上工作
$.ajax({
url : 'http://www.othersite.com/GetUrl?Callback=?',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
type : 'GET',
timeout : 5000,
cache : false,
crossDomain : true,
async : true,
data : { id : 100, noCache : new Date().getTime() },
beforeSend : function(XMLHttpRequest) { alert('Sended!'); },
complete : function(XMLHttpRequest, textStatus) { alert('Completed with status: ' + textStatus) },
success : function(data){ alert('Success with response:' + data.response ); },
error : function(xhr, textStatus, errorThrown){ alert('Error: ' + textStatus); }
});
iPad 上的提醒
Sended!
Completed with status: timeout;
Error: timeout
IE (7,8,9,10,11)、Firefox、Chrome、Opera、Safari Desktop 中的警报
Sended!
Completed with status: success
Success with response: http://www.google.com/
服务器应用(平均响应时间为 50 毫秒)
echo $_GET['Callback'].'('.json_encode(array('response' => 'http://www.google.com/')).')';
服务器响应标头
Access-Control-Allow-Origin: *
Cache-Control: no-cache
Connection: close
Content-Length: 152
Content-Type: application/json; charset=utf-8
Date: Tue, 02 Dec 2014 09:52:46 GMT
Pragma: no-cache
服务器响应正文
jQuery19109435868220625793_1417512417785({"response": "http://www.google.com/"})
在服务器日志中有来自 iPad 的请求,但显示来自其他浏览器的所有请求。
为什么会这样?
【问题讨论】:
-
来自 iPad 的请求似乎在服务器上超时。如果没有看到服务器在这个请求上做了什么,几乎不可能回答这个问题。
-
简单
echo $_GET['Callback'].'('.json_encode(array('response' => 'http://www.google.com/')).')'; -
您的服务器证书是否受保护?
-
@faby 没有证书
标签: javascript jquery ajax ipad