Error: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file' : AngularJS SPA

匿名 (未验证) 提交于 2019-12-03 01:20:02

问题:

I'm very new to Angular SPA and for the first time I get a code by Googling and try to run. But I get some errors in Console. I couldn't figure out why, I found list of following Console errors:

XMLHttpRequest cannot load file:///C:/Users/hp/Downloads/single-page-app-angularjs-master/home.html. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

Error: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file:///C:/Users/hp/Downloads/single-page-app-angularjs-master/home.html'. XMLHttpRequest cannot load file:///C:/Users/hp/Downloads/single-page-app-angularjs-master/about.html. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

Error: [$compile:tpload] http://errors.angularjs.org/1.3.3/$compile/tpload?p0=home.html

     Single page web app using Angularjs   

回答1:

On Windows:

chrome.exe --allow-file-access-from-files 

or

chrome.exe --allow-file-access-from-files --disable-web-security 

On Mac:

open /Applications/Google\ Chrome.app/ --args --allow-file-access-from-files 


回答2:

i faced something Like that and resolved by using application server like Glassfish ...

in other words using http:// protocol instead of file://



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!