Tuesday, 29 May 2018

AJAX and IE - Unable to get property error

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({
        url:"/search-ajax/" + window.location.search + "&pagination=" + page,
        dataType:$.browser.msie ? "text" : "xml",
        type:"GET",
        success: function(data) {
            var xml;
            if (typeof data == "string")
            {
                xml = new ActiveXObject("Microsoft.XMLDOM");
                xml.async = false;
                xml.loadXML(data);
            }
            else
                xml = data;

            $("#wait-element-container").remove();

            // error happens here:
            var ajax_html = $(xml).find("#search-ajax-content").html();
            $("#postload-target").append(ajax_html);
        }
    });



from AJAX and IE - Unable to get property error

No comments:

Post a Comment