Wednesday, June 5, 2024
 Popular · Latest · Hot · Upcoming
151
rated 0 times [  153] [ 2]  / answers: 1 / hits: 9555  / 11 Years ago, wed, december 4, 2013, 12:00:00

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?


More From » php

 Answers
2

This 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.com/2013/08/accessing-external-apis-with-angularjs.html


[#49864] Tuesday, December 3, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
parisc

Total Points: 438
Total Questions: 119
Total Answers: 119

Location: Turkmenistan
Member since Sat, Apr 16, 2022
2 Years ago
;