【发布时间】:2018-05-25 16:03:57
【问题描述】:
在 IE 上使用 AJAX(在 IE11 中测试)时,我在行 var ajax_html = $(xml).find("#search-ajax-content").html(); 上收到以下错误 Unable to get property ‘replace’ of undefined or null reference。此代码在其他浏览器(Chrome、FF 和 Safari)上运行良好。
有没有人在使用 AJAX 之前遇到过这个问题?我不确定如何解决这个问题。任何帮助表示赞赏!谢谢!!
$.ajax({
type:"GET",
dataType:"xml",
url:"/search-ajax/" + window.location.search + "&pagination=" + page,
success: function(data) {
var xml = data;
if (page == 1)
{
$("#wait-element-container").remove();
// Issue is happening here only on IE!
var ajax_html = $(xml).find("#search-ajax-content").html();
$("#postload-target").append(ajax_html);
}
}
});
【问题讨论】:
-
嗯,我刚刚通读了一遍。我不是我应该如何等待这个元素加载?有什么想法吗?
-
我不太确定是否诚实。我会尝试使用他在 cmets
if (typeof myVar !== 'undefined') { ... }中提到的类型检查。我会给你一个打击,希望其他人会加入。 -
谢谢。我很感激!希望其他人加入...我有点卡住了!
-
IE为什么要设置dataType为text?
标签: javascript jquery ajax