XMLHttpRequest cannot load ...Google Chrome cross domain problem

When the HTML page calls the public web service through Ajax, the browser request is sent successfully, but the response xhr.status==0 , the console reports the following error

XMLHttpRequest cannot load http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

The server is a public network and allows cross-domain access, so the reason lies in the client, that is, the browser - Google Chrome does not support cross-domain access by default .

Solution:

Close the browser window -> Right click on the Google Chrome icon -> Properties. The Properties dialog box pops up.  Add --args --disable-web-security --user-data-dir at the end of the target bar  to allow the browser to allow cross-domain access

Open the browser and display the following information indicating that the browser has been changed to allow cross-domain access

Of course, if you don't frequently perform browser-based cross-domain access, it is recommended not to enable cross-domain access.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325950867&siteId=291194637