Convert to IE9 below $. Ajax to return “no transport” across domains

Programmer algorithm practice must read, common Java API skills to share>>>

$.ajax({
            type: "POST",
            async: false,
            contentType: "application/x-www-form-urlencoded;charset=UTF-8",
            xhrFields: {
                withCredentials: true
            },
            url:url,
            data:data,
            success:function (response) {
                arr = response.Data.ListData;
            },
            error:function (XMLHttpRequest, textStatus, errorThrown) {
                alert(XMLHttpRequest.readyState);
                alert(textStatus);
            }
        });

  

The

code is as above. I thought it was a problem with the code, but later, I found that IE8 does not support CORS protocol, that is, access control allow origin: * added by background config

the solution is as follows:

Add jQuery. Support. CORS = true before $. Ajax

Or, add in $. Ajax

crossDomain:true,
dataType:'jsonp',
jsonp:'callback',

Original text https://blog.csdn.net/slzll/article/details/73175971

Similar Posts: