[英]Error JS in a feature writing html in IE11
在IE11中執行此功能時,我有一個小錯誤:
function clearText(someText){
return someText.replace(/(\r\n|\n|\r)/gm,"");
}
$.getJSON('/getElements/', callback)
.done(function(fragments){
$.each(fragments, function(propertyName,value){
if (clearText(value.trim())!==""){
$("."+propertyName).empty().append(clearText(value));
//$("."+propertyName).html(clearText(value));
//document.getElementsByClassName(propertyName)[0].innerHTML = clearText(value);
}
});
})
.fail(function(jqXHR, textStatus, errorThrown) {
console.log(textStatus);
});
在所有其他瀏覽器中,都沒有問題,empty()。append()可以正常工作。 但是IE11不接受empty.append,.html或.innerHTML,但我的數組“碎片”中有很多數據。
有人可以看到問題出在哪里嗎?
謝謝。
K.
好吧,我想我解決了問題。 當我使用.getJson時,IE使用緩存(getJson的默認緩存為true),但是FF和其他不使用此緩存。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.