jQuery $.ajax Not Working in IE8 but it works on FireFox & Chrome

前端 未结 6 2134
臣服心动
臣服心动 2020-12-17 01:58

I have the following ajax call which works perfectly in Firefox and Chrome but not IE:

function getAJAXdates( startDate, numberOfNights, opts ) {

    var mo         


        
6条回答
  •  独厮守ぢ
    2020-12-17 02:34

    What version of jQuery are you using?

    If you check jquery's code, parsererror is thrown when jQuery.httpData() is called. Here's the code from jquery:

    if ( status === "success" ) {
      // Watch for, and catch, XML document parse errors
      try {
        // process the data (runs the xml through httpData regardless of callback)
        data = jQuery.httpData( xhr, s.dataType, s );
      } catch(err) {
        status = "parsererror";
        errMsg = err;
      }
    }
    

    Maybe jQuery.httpData() is worth looking at. That is, you can check if jQuery.parseJSON is called and if it indeed returns an object.

    if ( typeof data === "string" ) {
      // Get the JavaScript object, if JSON is used.
      if ( type === "json" || !type && ct.indexOf("json") >= 0 ) {
        console.log(data); //add this
        data = jQuery.parseJSON( data );
        console.log("data parsed successfully"); //add this
    

提交回复
热议问题