我无法在 Angular 1.2.13 中创建成功的获取请求。
var getProgress = function() {
var promise = $http({method: 'GET', url: 'http://localhost:8080/project/local/some/getStatus'});
promise.then(function(success) {
alert(JSON.stringify(success));
}, function(error) {
alert(JSON.stringify(error));
}, function(notify) {
alert(JSON.stringify(notify));
});
};
所以我试图从我的 REST Web 服务接收一些 JSON。为了测试该服务,我从浏览器(IE9、Firefox 27、Chrome 33)访问它,在所有浏览器中都可以正常工作。
但是,上面使用 angular 的代码总是提示我错误:
*{"data":"","status":404,"config":{"transformRequest":[null],"transformResponse":[null],"method":"GET","url":, "http://localhost:8080/project/local/some/getStatus"
" headers":{"Accept":"application/json, text/plain, / "}}}*
使用wireshark我检查 HTTP 请求和 HTTP 响应,从浏览器和角度调用 Web 服务都返回 200和所需的 json 对象!!然而,角度提示我 404。
当我使用 ANGULAR 从 Firefox 发出获取请求并使用 Findbugs 进行调试时,在控制台中我得到 HTTP 代码 200,但 Angular 说 404。尝试调试 Angular 的代码无济于事,看不到任何奇怪的东西。
上面的代码在 IE9 中可以正常工作!
任何建议表示赞赏。