我是 AngularJS 的新手。我将它与 ionic 框架一起使用。我正在尝试调用 json Web 服务,但它总是返回 404。
当我在浏览器中尝试时,它工作得很好。
这是我的代码:
function FetchCtrl($scope, $http) {
$scope.fetch = function() {
$http({method: 'GET', url: 'http://example.com/anyservice'}).
success(function(data, status, headers, config) {
alert("data "+data);
}).
error(function(data, status, headers, config) {
alert("error "+status);
});
};
}
最佳答案
使用 Chrome 或 FireFox 开发者工具并打开“网络”选项卡,然后尝试一下,看看发生的实际请求是什么,这应该可以帮助您找到问题。
关于javascript - Angularjs - 调用 json Web 服务总是返回 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24381019/