【发布时间】:2012-06-07 06:48:23
【问题描述】:
我正在我的程序中使用 jQuery 的 .ajax() 检索 HTML 数据。
在 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 行找到我的代码。脚本文件的名称会很长,因为它会在运行时合并其他脚本文件。
更新
我在 localhost 上实现了相同的解决方案,它在所有浏览器上都运行良好。是服务器问题吗?
更新 2
问题已解决,我猜这是服务器上的缓存问题,因为我在不同的位置安装了我的项目的新副本,并且它在所有浏览器中都可以正常工作。
【问题讨论】:
-
你试过 alert( $(testdata).html() ); ?
-
检查这个回复,它对我有用:stackoverflow.com/a/12057929/15329
标签: jquery ajax internet-explorer-8 internet-explorer-7