【问题标题】:jQuery .ajax and .appendTo in IE8IE8 中的 jQuery .ajax 和 .appendTo
【发布时间】:2013-11-24 04:18:30
【问题描述】:

在各种浏览器中打开以下页面时,我看到了奇怪的行为:

<html>
    <head>

        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
        <script>
            $(document).ready(function() {
                $.ajax({
                        url: "http://development.collegian.com/2013/06/27/newspaper-racks-looking-thin-on-campus/",
                        cache: false,
                        success: function(result) {
                            var test = $($.parseHTML(result));
                            test.appendTo("body");
                        }
                });
            });
        </script>
    </head>
    <body>
        Test.
    </body>
</html>

这在 Firefox 和 IE10 中按预期工作(加载指定的 URL),但是当我在 IE 开发人员工具中打开 IE8 浏览器模式和 IE8 标准时,无法加载 AJAX 页面。 IE 中不会抛出任何错误。

感谢您的帮助!

【问题讨论】:

    标签: jquery internet-explorer internet-explorer-8 cross-browser


    【解决方案1】:

    在 ie 8 中写入完整的 url

    url: "http://development.collegian.com/2013/06/27/newspaper-racks-looking-thin-on-campus/index.php(or any full page name(home.html/home.php)
    
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^set your file name here
    

    因为IE低版本需要完整的url

    【讨论】:

    • 抱歉,这不起作用。我尝试使用 console.log(result) 从 ajax 函数输出结果,它看起来不错。我认为 IE8 出错的地方在于 appendTo() 调用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-16
    • 1970-01-01
    • 1970-01-01
    • 2010-11-14
    • 2013-09-20
    • 2015-04-25
    • 1970-01-01
    相关资源
    最近更新 更多