如何在IE7 +中使jQuery $('#div').html()工作? [英] How can I get jQuery $('#div').html() to work in IE7+?
本文介绍了如何在IE7 +中使jQuery $('#div').html()工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用以下代码编写了ajax请求来即时更改div:
I have written ajax requests to change divs on the fly by using the code below:
$(document).ready(function(){
$.ajax({
type : 'GET',
url : url,
success : function(data){
$('#some_div').html(data);
}
});
});
它在Chrome,FF,Safari和移动设备中都很好用,但在IE7 +中却不返回任何内容.难道我做错了什么?还是,这是一个令人讨厌的IE错误?如果是这样,我该如何解决?
It works great in Chrome, FF, Safari and mobile devices, but it returns nothing in IE7+. Am I doing something wrong? Or, is this an annoying IE bug? If so, how do I work around it?
编辑 这是我要插入的文件的HTML:
EDIT Here is the HTML of the file I'm trying to pull in:
<!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失败,而其他一些浏览器则不在乎.
Is the HTML you receive from the AJAX-request valid? If not this will result in IE failing, while some of the other browsers don't care.
这篇关于如何在IE7 +中使jQuery $('#div').html()工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文