I have a global ajax success function set up to detect an ajax submission on a wordpress page. Depending on the result, I would like to convey the response text to the user on the page. Usually I would just create the ajax post myself, and simply write any response to the screen with my own function - i.e.:
success : function(data) {
theResult = data;
if (data.indexOf("the response I'm looking for") > -1 ) {
$(".targetdiv").append(data');
}
}
But, this ajax request is performed by a wordpress plugin, which I do not want to modify and thus lose any modifications when the plugin is updated. So I found this general ajax success function:
$(document).ajaxSuccess(function(event, request, options) {
var data = request.responseText;
if (data.indexOf("the response I'm looking for") > -1 ) {
$(".targetdiv").append(data');
}
});
This works perfectly in Firefox and Chrome, and MS Edge Browser, but not in any earlier versions of IE including 9, 10 & 11 or earlier versions of Safari (8 and earlier).
It fails in those browsers by not getting the request.responseText
at all.
I did some testing trying this: $parseJSON(request.responseText)
to no avail.
I was just wondering what is different about the earlier versions of Explorer and Safari that would cause this to not work in those browsers.