jquery - 如何让 jQuery $ ('#div' ).html() 在 IE7+ 中工作?

标签 jquery internet-explorer

我已经使用下面的代码编写了动态更改 div 的 ajax 请求:

$(document).ready(function(){   
    $.ajax({    
        type : 'GET',
        url : url,
        success : function(data){ 
            $('#some_div').html(data);
        }
    });
});

它在 Chrome、FF、Safari 和移动设备中运行良好,但在 IE7+ 中不返回任何内容。难道我做错了什么?或者,这是一个烦人的 IE 错误吗?如果是这样,我该如何解决它?

编辑 以下是我尝试提取的文件的 HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Store Notes</title>
    <meta name="description" content="" />
    <meta name="keywords" content="" />      
    <link type="text/css" href="/css/smoothness/jquery-ui-1.8.11.custom.css" rel="stylesheet" media="all" /> 
    <link type="text/css" href="/css/colorbox.css" rel="stylesheet" />  
    <link type="text/css" href="/css/rep.css" rel="stylesheet" /> 
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js"></script> 
    <script type="text/javascript" src="/js/rep/global.js"></script>   
    <script type="text/javascript" src="/js/jquery.colorbox-min.js"></script>

</head>

<body><table style="width:100%;" cellspacing="12px">    
<tr><td><b>Some Guy</b> <span class="small">Apr 28th</span><br />testing123</td></tr><tr><td><b>Some Guy</b> <span class="small">Apr 28th</span><br />testing123</td></tr></table>
</body>
</html>

最佳答案

您从 AJAX 请求收到的 HTML 是否有效?否则,这将导致 IE 失败,而其他一些浏览器则不在乎。

关于jquery - 如何让 jQuery $ ('#div' ).html() 在 IE7+ 中工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5823233/

相关文章:

javascript - 为什么这里没有设置Large Image Path?

windows - Windows 7 和 Windows 8(台式机/Metro)之间的 Internet Explorer 10 有何不同?

javascript - 如何知道 Internet Explorer(IE) 中的 cookie 过期时间

html - 如何在更大的缩放级别显示图像后的产品信息

css - @font-face 即问题

javascript - 如何检查 Svelte 应用程序的浏览器兼容性?

javascript - 在 javascript 中设置 CSS 渐变?

javascript - $.ajax 工作,但 $.post 失败

javascript - 导航栏始终显示在轮播图像后面

javascript - 我的 table 上的 jquery 表排序器出现问题,我收到了 json 文本墙