私のサービスは304
を返しますが、jQuery Ajaxは200 OK
の結果に変換しているようです。200の代わりにjQuery Ajaxから304を取得するには?
$.ajax({
url: '/api/items',
type: 'GET',
dataType: 'json',
contentType: 'application/json',
ifModified:true,
cache: false,
statusCode: {
304: function() {
alert("not modified"); // does not fire
}
},
complete: function (xhr, status) {
console.log(xhr.status); // 200
}
}
});
フィドラーで、私はサービスが正しく304
を返すことがわかります。
は、これが私の要求です。
jQueryはなぜそれを200
に変換しますか?
可能重複[ jQuery.ajax()リクエストのヘッダーステータスが "304 Not Modified"であるかどうかを確認してください。](http://stackoverflow.com/questions/5173656/how-to-check-if-jquery-ajax-request-header-status-is -304-not-modified) – apsillers