【发布时间】:2015-09-22 00:43:10
【问题描述】:
$.ajax({
type: "GET",
url: "http://myweb/php",
success: function (data){
alert(data);
},
error:function(xhr,textStatus,err)
{
alert("readyState: " + xhr.readyState);
alert("responseText: "+ xhr.responseText);
alert("status: " + xhr.status);
alert("text status: " + textStatus);
alert("error: " + err);
}
});
我得到的结果是:
readyState:0
responseText:""
status:0
text status:error
error:""
我尝试在我的 php 中添加标题,但仍然无法正常工作。在我将 xcode 更新到 7.0 并将 ios 模拟器更新到 9.0 之前,ajax 代码工作。
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
【问题讨论】: