【发布时间】:2015-04-28 10:23:32
【问题描述】:
Angular $resource 在调用成功时总是调用错误回调。我已通过 Fiddler 验证服务器返回的 json 成功代码为 200。请记住,这是在 Asp.net MVC 视图中发生的。 restful 调用的返回值是单个对象。
//Setup
$scope.targetResource = $resource(baseUrl + ":target", { target: @target" });
// Triggering event
$scope.handleEvent = function() {
$scope.targetResource.get({ target: "somevalue" },
function() {
// Never raises this function
},
function (responseError)
{
// Raises this function everytime with this response
// {
// "data": null,
// "status": 0,
// "config": {
// "method": "GET",
// "transformRequest": [null],
// "transformResponse": [null],
// "url": "(the correct url)",
// "headers": {
// "Accept":"application/json, text/plain, */*"
// }
// },
// "statusText":""
//}
}
});
我的设置中是否缺少某些内容?它正在服务器上调用正确的方法并传递正确的值。
【问题讨论】:
标签: javascript angularjs model-view-controller resources ngresource