我有一個JSON GET請求,當我使用curl在PHP把它完美的作品,但是當我嘗試做同樣的事情的getJSON(這是要求),所有我回來當我使用下面的代碼時,狀態是錯誤的。我怎樣才能確切知道錯誤是什麼?我不知道如果我發送錯誤參數的請求是否超時,或者它可能是什麼。由於捲曲工作,JSON不工作
$.getJSON(url, function(data,status,xhr) {
if (status == "success"){
alert ("got the data"+data);
}else if (status == "timeout"){
alert("Something is wrong with the connection");
}else if (status == "error" || status == "parsererror"){
alert("An error occured");
}else{
alert("datatosend did not change");
}
})
您可能會被同源策略阻止?錯誤說的是什麼? – adeneo
'console.log(xhr.status,xhr.statusText);' – epascarello