【问题标题】:Error JS in a feature writing html in IE11在 IE11 中编写 html 的功能中出现错误 JS
【发布时间】:2015-12-08 08:55:00
【问题描述】:

我在 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.

【问题讨论】:

  • 你到底遇到了什么错误?
  • IE11 不写任何 HTML 在:$("."+propertyName).empty().append(clearText(value));
  • 我们可以看看你的 html 吗? :) IE 比 Chrome 或 Firefox 对 html 错误更敏感。
  • 您在控制台中看到任何错误消息吗?如果不是,您的问题标题具有误导性
  • 当我使用控制台时,我没有soucy。如果我使用 alert(),我可以看到所有数据

标签: javascript jquery html json getjson


【解决方案1】:

好的, 我想我解决了这个问题。 当我使用.getJson时,IE使用了一个缓存(getJson的默认缓存为true),但FF等不使用这个缓存。

【讨论】:

    猜你喜欢
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    • 2021-09-30
    • 2016-08-11
    • 2019-09-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多