Spring MVC でMalsup の JQuery Form プラグインを使用して、いくつかの Ajax ルックアップを実行しています。
IE で問題が発生しています (サプライズ サプライズ)。
Javascript コード:
var options = {
type: "POST",
cache: false,
success: displayList,
error: errorList,
url: 'test.jsp',
dataType: 'json'
};
$('form').ajaxSubmit(options);
function displayPolicyList(responseText, statusText, xhr, $form)
{
alert(responseText); // Works in all browsers
}
function errorList(xhr, ajaxOptions, thrownError)
{
alert(xhr.responseText); // Fine in firefox etc, NULL in IE
}
春のコード:
@ResponseBody
public ResponseEntity<Map<String, String>> erroResponse()
{
Map<String, String> error = new TreeMap<String, String>();
error.put("error", message);
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentType(MediaType.TEXT_PLAIN);
return new ResponseEntity<Map<String, String>>(error, responseHeaders,
HttpStatus.INTERNAL_SERVER_ERROR);
}
成功すると、すべてのブラウザですべて正常に動作します。JSON 応答を問題なく読み取って解析できます。JSON 応答でエラー メッセージと共に 500 を返すと、問題が発生します。firefox、chrome などでは、すべて期待どおりに動作し、errorList は JSON 応答を解析できます。
ただし、IE では JSON は null です。JQuery フォーム プラグインで、同じクロス オリジン エラー ( can't access response document: TypeError: Access is denied. )が表示されることがわかります。 詳細は次のとおりです。
アクセスが拒否されました。IE の jquery.form.js で
ただし、クロスドメインは単一のアプリケーションであるため、アクセスしていません。
JQuery プラグインでは、問題と思われるブロックは次のとおりです。
function getDoc(frame) {
var doc = frame.contentWindow ? frame.contentWindow.document : frame.contentDocument ? frame.contentDocument : frame.document;
return doc;
}
コントローラーから HttpStatus.CREATED を返すと正常に動作しますが、サーバーからの障害イベントにより、上記の関数が例外をスローします。
何か案は?