admin管理员组文章数量:1393392
While try to run the following function in angular
$scope.login = function (user, LoginForm) {
$http.get('http://localhost/Angular/index.php/core/login').success(function (data) {
$scope.message = data;
});
};
it shows the following error
(Im working with this code in webstorm)
Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost/Angular/index.php/api/login:0
Failed to load resource: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:63342'
is therefore not allowed access.
http://localhost/Angular/index.php/api/login:0
XMLHttpRequest cannot load http://localhost/LAngular/index.php/api/login
. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:63342'
is therefore not allowed access.
How to fix this?
While try to run the following function in angular
$scope.login = function (user, LoginForm) {
$http.get('http://localhost/Angular/index.php/core/login').success(function (data) {
$scope.message = data;
});
};
it shows the following error
(Im working with this code in webstorm)
Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost/Angular/index.php/api/login:0
Failed to load resource: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:63342'
is therefore not allowed access.
http://localhost/Angular/index.php/api/login:0
XMLHttpRequest cannot load http://localhost/LAngular/index.php/api/login
. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:63342'
is therefore not allowed access.
How to fix this?
Share Improve this question asked Dec 4, 2013 at 9:15 user2853731user2853731 1- This answer (jquery related) can help you. stackoverflow./questions/19821753/… Even it is jquery it will show you how to deal with Origin Policy. – Andrej Kaurin Commented Dec 4, 2013 at 9:19
1 Answer
Reset to default 4This indicates the Api doesnt support Cross origin requests
so the request should be 'JSONP'
$http.jsonp('http://localhost/Angular/index.php/core/login')
For more about this issue : http://www.arunisrael./2013/08/accessing-external-apis-with-angularjs.html
本文标签: javascriptFailed to load resource error in Angular jsStack Overflow
版权声明:本文标题:javascript - Failed to load resource error in Angular js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744640671a2617099.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论