I have that simple code :
$http.get(\"/api/test\")
.success(function (data, status, headers, config) {
console.log(data);
return data;
If you are using AngularJS version 1.1.1 or greater...
Does appending '.json' work?:
$http.get("/api/test.json")
.success(function (data, status, headers, config) {
console.log(data);
return data;
}).error(function (data, status, headers, config) {
alert("error");
return status;
});
If so, it can also be fixed with:
myModule.config(['$httpProvider', function ($httpProvider) {
$httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
}]);
See this => Angular JS Fails After Upgrade from 1.1.0 to 1.1.1