【问题标题】:jQuery + ie8 'Object doesn't support this property'jQuery + ie8 '对象不支持此属性'
【发布时间】:2013-08-14 05:23:16
【问题描述】:

我遇到了以下错误

在我设置 $content 变量的那一行:

var loadResource = function(url, params, callback) {
    WHOAT.networking.getToServerWithAjax(url, params, function (response) {
        //var $content = $($.parseHTML(response.trim()));
        var $content = $(response.trim());
        var $container = $('#dashboard-display');
        var $content_to_hide = $container.children();

        $.when($content_to_hide.fadeOut('fast')).then(function () {
            $content.hide();
            $container.append($content);

            $content.fadeIn('fast', function(){
                $content_to_hide.remove();

                if(callback) {
                    callback();
                }
            });
        });
    });
}

本来以为跟parseHTML有关,于是在下一行试了var $content = $(response.trim());,但还是抛出这个错误。

响应基本上只是用于呈现此代码加载的小部件的 HTML。

对我可能需要做些什么才能让它在 ie8 中工作有什么想法吗?

【问题讨论】:

    标签: jquery methods properties internet-explorer-8


    【解决方案1】:

    IE8 中没有trim,但 jQuery 提供了one

    改变

        var $content = $(response.trim());
    

        var $content = $($.trim(response));
    

    【讨论】:

    • 另外,理想情况下,您希望将注释掉的版本与 $.parseHTML 一起使用,但您仍应修剪它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多