How to fix a problem where browsers such as Chrome don't support local AJAX requests

Source: Internet
Author: User

XMLHttpRequest cannot load file:///D:/WWW/angularlx/ui-router-test/template/content.html. Cross origin requests is only supported for protocol schemes:http, data, Chrome, chrome-extension, HTTPS, Chrome-extensi On-resource.

The above is the Chrome console error message, the message is obvious, XMLHttpRequest can not load the HTML file, Local is prohibited cross-domain request, does not support the FILE://protocol, in fact, This is the result of my direct double-click on the index.html file, in fact, I installed the phpstudy kit on my own computer, I passed http://127.0.0.1/......./ Index.html is able to open the page normally, and will not error, this is of course, such as the above error message half sentence, cross-domain Request Support Protocol has HTTP!

In fact, prohibit cross-domain is the browser's security restrictions, in every browser, such as in Chrome, Firefox, Opera, 360 is the same, the same will report the above error, but can be set to bypass this restriction (if the front-end code is often recommended to install a Web container in this machine ...) , the common way is to right-click the Chrome shortcut, select "Properties", add "--allow-file-access-from-files" to "target" under "shortcuts" (there is a space at the front) and restart Chrome. Such as:

There is also a way to not tamper with the shortcut, which is:

1, cmd into the DOS environment

2. Enter \google\chrome\application> under DOS (Chrome.exe directory)

3, the Operation command Chrome.exe--allow-file-access-from-files;

Note: After running the 3rd step, this time will start Chrome browser, do not close it, using Chrome to open the previous error HTML file, found normal, no error, but I now turn chrome off, In the use of Chrome code this HTML file will be error, this means that this method is only valid for this open chrome, closed and then open is invalid, for convenience, or to use the above to modify the shortcut properties of the method bar!

Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source. Internet + times, always want to keep learning, together with the thousand front php,dream It Possible.

How to fix a problem where browsers such as Chrome don't support local AJAX requests

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.