【发布时间】:2016-05-31 16:12:27
【问题描述】:
我有一个简单的 Web API 和 ionic/angularJs 客户端,用于 CRUD 操作。当我在服务器上发送数据进行编辑时,我会得到一个错误。
这是发送数据格式和错误的图片:
angularJS 更新方法
$scope.save = function (location) {
var obj = {
//locationId: $scope.id,
locationName: location.locationName,
locationDescription: location.locationDescription
};
console.log('output: ' + JSON.stringify(obj));
$http.put(ServerPath + "/" + $scope.id, $scope.id, obj).success(function (data) {
$state.go('tab.home');
}).error(function (data) {
$scope.error = "An error has occured while adding! " + data;
console.log('Error: ' + data);
});
};
【问题讨论】:
-
请附上源代码
-
@RubenYeghikyan 我添加了 angularJS 方法
-
确保您正在解析服务器接受的数据。尝试使用 web 工具或 http 插件来查看标题。尝试修改您的请求并重新发送。
-
@RubenYeghikyan 谢谢,我想说我在纯 angularjs 中测试了我的项目,它会很好并且没有任何错误。但是当我想在 Ionic 项目中使用此代码时,它不起作用。我想知道添加或删除操作如何正常工作,但只有编辑/更新功能有错误!
标签: javascript angularjs asp.net-web-api ionic-framework