The code is as follows:
$.ajax({
type:'post',
url:url,
data:data,
dataType:'json',
xhrFields:{
withCredentials:true
/*
Corresponds to the code in the server
response.addHeader("Access-Control-Allow-Credentials","true");
response.addHeader("Access-Control-Allow-Origin",origin);
*/
},
crossDomain:true,
success:function(res){
//。。。
},
error:function(resData){
//。。。。
}
});
Open chrome, open fiddler, visit the page, click the button to run, the browser seems to be normal, Fiddler gets an http200 ~! It seems that cross domain access can be achieved by setting crossdomain = true, but it is not perfect
Open IE, test again,,, report an error!?There is no response in fiddler, even the request is not sent out. Strange?Google… Found in an article in stackoverflow:
http://stackoverflow.com/questions/3362474/jquery-ajax-fails-in-ie-on-cross-domain-calls
In other words, IE8 uses the so-called xdomainrequest instead of XMLHttpRequest, but jQuery only supports XMLHttpRequest
At present, the best solution is to use jsonp
Similar Posts:
- Convert to IE9 below $. Ajax to return “no transport” across domains
- The front-end XMLHttpRequest object sets an error in the request header
- How to deal with the problem of failed to execute ‘send’ on ‘XMLHttpRequest’: failed to load ‘URL’
- [Solved] Unapp H5 Error: Access to XMLHttpRequest at ‘http://www.localtest.com/api/api/v1/job/getPositionList’…
- XMLHttpRequest status=0 (All You Should Know)
- Access to XMLHttpRequest at ‘http://localhost:9990/’ from origin ‘http://IP:Port’ has been blocked by CORS policy…more-private address space `local`
- Python crawling picture prompt urllib.error.httperror: http error 403: forbidden solution
- [tran] tunnel to… 443 appears when Fiddler grabs packets
- Problems encountered by Fiddler packet capture tool
- error – canvas- Failed to execute ‘toBlob’ on ‘HTMLCanvasElement’: Tainted canvases may not be exported.