gpt4 book ai didi

jQuery .find() 在 Internet Explorer 7 和 Internet Explorer 8 中不起作用

转载 作者:行者123 更新时间:2023-12-01 04:20:45 24 4
gpt4 key购买 nike

我正在检索HTML在我的程序中使用 jQuery 的 .ajax() 获取数据。

Internet Explorer 9、Chrome、Firefox 和 Opera 一切顺利.

Internet Explorer 7 中存在问题和 Internet Explorer 8 .

我的 jQuery 代码如下。

$j.ajax({
type:'POST',
datatype:'HTML',
url:processUrl,
success:function(data){
alert(data);
var testdata = $j(data).find(".category-products");
alert(testdata.html());
$j(".col-main .category-products").empty().replaceWith(testdata);
},
complete: function(){
//Doing something
}
});

现在,当我提醒 data 时,我会获取 HTML 数据(在 Internet Explorer 7 和 Internet Explorer 8 中也是如此)。

但是,当我提醒 testdata 时,我在 Internet Explorer 7 和 Internet Explorer 8 中得到 null

我该如何解决这个问题?

您可以查看错误here (点击数字进行分页)-

如果您正在调试,那么您会在第 11949 行找到我的代码。该脚本文件将有一个很长的奇怪名称,因为它在运行时合并其他脚本文件。

更新

我在本地主机上实现了相同的解决方案,并且它在所有浏览器上运行良好。是服务器问题吗?

更新2

问题已经解决,我猜这是服务器上的缓存问题,因为我在不同的位置安装了项目的新副本,并且它在所有浏览器中都工作正常。

最佳答案

success:function(data){
alert(data);
var temp = $j('<div/>').append(data); // Here is the trick:
// Set the data to a
// temporary element.
var testdata = $j(temp ).find(".category-products"); // Then find
alert(testdata.html());
...
},

如果上述方法不起作用,则采用隐藏 div。假设:

<div id="imhidden"></div>

然后执行以下操作:

success:function(data){
alert(data);
$j('#imhidden').html(data); // Here is the trick:
// Set the data to that
// hidden div.

var testdata = $j('#imhidden').find(".category-products"); // Then find
alert(testdata.html());
...
},

关于jQuery .find() 在 Internet Explorer 7 和 Internet Explorer 8 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10860254/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com