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