これはクロスサイトリクエストの問題ではなく、私の質問に対するほとんどのグーグルの回答は次のようなものです。Jquery ajaxrequest xhr.status code 0 but html status code 200
jquery関数.getおよび.loadを使用してajaxリクエストを作成しようとすると、xhr.status 0 och xhr.statusText "error"が表示されます。しかし、Firebugでは、リクエストされたページにhtmlステータスコード200がロードされ、レスポンスのテキストを読むことができ、レスポンスヘッダーが正常に表示されます。
マイコード:
function GetProjectTask(e) {
var loader = $('#' + e + 'tasks div.loader');
var content = $('#' + e + 'tasks div.content');
var img = $('#' + e + 'tasks img.collapseimg');
if (loader.html() == null || loader.html().trim() == '') {
if (content.html() == null || content.html() == '') {
img.attr('src', 'images/expanded.gif');
loader.html('<img src="images/loading.gif" alt="Wait..."> Loading support tasks');
content.load('includes/my' + e + 'tasks.php',
function (response, status, xhr) {
if (status == "error") {
var msg = "Sorry but there was an error: ";
alert(msg + xhr.status + " - " + xhr.statusText);
}
}
);
return;
}
}
content.empty();
loader.empty();
img.attr('src', 'images/collapsed.gif');
}
サーバー:IISのv.7.5 のjQuery:v1.6.2
任意のアイデア?
代替リソースを読み込もうとしましたか?例えば、静的なhtmlファイルのように。 あなたのPHPファイルからのあなたの応答のコンテンツタイプは何ですか? – Lewis
うん。私の応答ファイルの内容は純粋なhtmlです。 – moiran
jqueryも最新バージョンに更新しようとしましたが、問題はないと私は疑っていました。そして問題は残っています。 – moiran