ajaxjsonリクエストとInternetExplorerで問題が発生しています。具体的には、ajaxリクエストは正しく動作しません。
私が使用しているもの:
OpenCart 1.5.3.1
jquery-1.7.1.min.js
jquery-ui-1.8.16.custom.min.js
Internet Explorer 9
PHP 5.2.9
これはリクエスト機能です:
function addToCart(product_id, quantity, option_id, option_value) {
quantity = typeof(quantity) != 'undefined' ? quantity : 1;
option_value = typeof(option_value) != 'undefined' ? option_value : 0;
option_id = typeof(option_id) != 'undefined' ? option_id : 0;
jQuery.ajax({
url: 'index.php?route=checkout/cart/add',
type: 'post',
cache: false,
data: 'product_id=' + product_id + '&quantity=' + quantity + '&option_id=' + option_id + '&option_value=' + option_value+'&rnd=' + Math.random(),
dataType: 'json',
success: function(jsonObj) {
$('.success, .warning, .attention, .information, .error').remove();
if (jsonObj['redirect']) {
location = jsonObj['redirect'];
}
if (jsonObj['success']) {
$('#notification').html('<div class="success" style="display: none;">' + jsonObj['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
$('.success').fadeIn('slow');
$('#cart-total').html(jsonObj['total']);
$('html, body').animate({ scrollTop: 0 }, 'slow');
}
}
});
}
PHP関数は以下を返します:
{"success":"Added to cart!","total":"1 product(s) - 52,48\u043b\u0432."}
これはすべてChrome、FFなどで正常に機能しますが、IEでは失敗します。
実際、IEは「成功」イベントを発生させません。
応答を取得する唯一の方法は、エラーハンドラーを使用することです。
その場合、jsonオブジェクトのステータスは200、statusTextはOKになります。
これは、Chromeで発生した成功イベント後のjsonオブジェクトです。
jsonObj: Object
success: "Added to cart!"
total: "1 product(s) - 52.48лв."
__proto__: Object
そこから「成功」および「合計」の値が使用されます。
これは、InternetExplorerでエラーイベントが処理された後のjsonオブジェクトです。
responseTextは、現在のページのhtmlソースを含む文字列です。
試してみましjQuery.ajaxSetup({cache: false});
たが、結果は同じです。
誰かがこの問題を抱えていましたか?または何かヒントはありますか?
これ以上のアイデアはありません。