我已经使用下面的代码编写了动态更改 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/