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 - $( "#hover"+item ) 不起作用,但 $( "#hover0") 起作用

javascript - jQuery iframe 滚动事件 (IE)

html - Internet Explorer 8 不为具有相同类的两个元素加载 CSS 的问题

css - 使用 :after and :hover:after button in IE11

javascript - 自动重启/重置倒计时器

jQuery .removeAttr ('style' ) 在 .animate() 之后不起作用

php - 使用ajax将变量传递给php文件不起作用

jquery - 显示 div 时出现部分边框

IE浏览器中的JQuery选择框焦点问题

java - 如何在 IE 11 中使用 Selenium webdriver 单击安全警告窗口?