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

编程入门 行业动态 更新时间:2024-10-28 14:25:55
本文介绍了如何让 jQuery $('#div').html() 在 IE7+ 中工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我已经使用下面的代码编写了 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/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3/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/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://ajax.googleapis/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.

这篇关于如何让 jQuery $(&amp;#39;#div&amp;#39;).html() 在 IE7+ 中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-23 08:51:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1039178.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:工作   amp   jQuery   html   div

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!