I'm getting the following error Unable to get property ‘replace’ of undefined or null reference
on line var ajax_html = $(xml).find("#search-ajax-content").html();
when using AJAX on IE (testing in IE11). This code is functioning fine on other browsers (Chrome, FF, and Safari).
Has anyone ever experienced this issue before using AJAX? I'm not exactly sure how to resolve this issue. Any help is appreciated! Thank you!!
$.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);
}
}
});
jQuery is able to parse text and query as HTML (as long as the text is valid html). Have you tried:
$.ajax({
type:"GET",
dataType:"text",
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);
}
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With