我有這個超級怪異的bug,在IE9中這個方法失敗。 什麼是超級奇怪的是,如果IE [開發工具]是開,方法不會失敗。我不知道如何通過打開窗口來改變腳本的執行。jQuery ajax在IE中失敗
當我用IE [Developer Tools]打開時執行這個腳本時,函數按預期執行。 當IE [開發工具]是封閉的,它執行:
alert("00000000000000000000000000000000000");
alert("4444444444444444444");
就是這樣,沒有其他警報被觸發。
我嘗試刪除timeout: 20000
和cache: false
,但它沒有幫助。
function postAssets(datapm) {
alert("00000000000000000000000000000000000");
$.ajax({
type: "POST",
url: "Igud.aspx/PostD",
cache: false,
contentType: "application/json; charset=utf-8",
data: '{"postedData":"' + datapm + '"}',
dataType: "json",
timeout: 20000,
tryCount: 0,
retryLimit: 10,
success: function (msg) {
alert("4444444444444444444");
console.log('success postAssets ' + msg.d);
},
complete: function (jqXHR, status) {
alert("44444444444aaaaaaaaaaaaaaaaaaaaaaaaaaaa44444444");
if (status == 'success' || status == 'notmodified') {
alert("aaaaaa");
console.log('complete postAssets' + jqXHR.responseText);
var obj = jQuery.parseJSON(jqXHR.responseText);
alert("bbbb");
// alert(parseInt(obj.d));
// alert(parseInt(obj.d) == 1);
if (parseInt(obj.d) == 1) {
$("#thxbox").html("TEST");
alert("ccc");
if ($("#Q3_3").attr('checked') == 'checked') {
$("#thxboxMd").dialog("option", { height: 470 }); alert("dddd");
$("#thxboxReg").show(); alert("eeee");
$("#thxbox").effect("pulsate", { times: 3 }, 1200); alert("ffff");
}
else {
$("#thxboxReg").hide();
$("#thxboxMd").dialog("option", { height: 180 });
}
$("#thxboxMd").dialog("open");
$("body").off("click", "#sbbtn");
$('body').on('click', '#sbbtn', function() {
$("#thxbox").html("TEST");
if ($("#Q3_3").attr('checked') == 'checked') {
$("#thxboxMd").dialog("option", { height: 470 });
$("#thxboxReg").show();
$("#thxbox").effect("pulsate", { times: 3 }, 1200);
}
else {
$("#thxboxReg").hide();
$("#thxboxMd").dialog("option", { height: 180 });
}
$("#thxboxMd").dialog("open");
});
}
else {
$("#thxbox").html("TEST");
$("#thxboxMd").dialog("open");
$("#thxbox").effect("pulsate", { times: 3 }, 900);
}
}
},
error: function (req, status, error) {
alert("444444444444411111111111111111112222222222222222444444");
this.tryCount++;
if (this.tryCount <= this.retryLimit) {
var offSet = this.tryCount * 1000;
getAssetsRecovery = this;
var retry = function() { $.ajax(getAssetsRecovery); };
setTimeout(retry, offSet);
console.log(arguments);
console.log('error postAssets' + error);
$("#thxbox").html("TEST");
$("#thxboxMd").dialog("open");
$("#thxbox").effect("pulsate", { times: 3 }, 900);
return;
}
console.log('error postAssets');
}
});
}
嘗試刪除IE瀏覽器緩存,看看會發生什麼 – Shyju
我做了它,我寫在OP –
嘗試使用'window.console.log ' –