I'm using jQuery to read an XML file. Sometimes the XML is empty, and I expect the error function (no_info) is executed because the file is not formatted according to the dataType.
In IE 10 the Error function is executed. But in Firefox (40.0.2) the success function (parse) is executed. Why both browsers behave differently and which one is correct?
$.ajax({
  url: '/~play/shout.xml',
  dataType: "xml",
  success: parse,
  error: no_info
});
                Looks like there's a bug in IE
how about you handle it yourself?
 function parseXml(xml) {
   if ($.browser.msie)  {
   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
     xmlhttp = new XMLHttpRequest();
   }else {// code for IE6, IE5
     xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   }
   xmlhttp.open("GET", "XML_file.xml", false);
   xmlhttp.send();
xmlDoc = xmlhttp.responseXML;
xml = xmlDoc;
} 
return xml;
}
previous answer
which JQuery version do you use? I use the most actual and with my ajax function I couldn't encounter any issues. That's my code
function sync(arg, callback){   //ajax result 
    $('.loader').show();
    $.ajax({ 
        method: 'GET',
        url: 'liveSearch.php',
        data: arg, // send argument and update
        success: function(data, status, xhr){
         $('.loader').hide();
         callback(data);
        },
        error: function(xhr, ajaxOptions, thrownError){
            console.log(thrownError);
        }
   });  
}
function onCallback(data) {
        result = data;
}
                        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