我想使用postData向服务器发送请求。(JSON)
我尝试了以下$http
请求,
var jsonData = {"id": 1, "name": "xxx", "designation": "developer", "department": "IT"};
$http({method: 'POST',
url: url,
data: jsonData,
headers: {'contentType': 'application/json'}
}).success(function() {
$scope.sucess = "Success";
}).error(function() {
$scope.errorMessage = "Failure";
});
和
$resource('/path/to/the/server',{},{update:{method: 'POST', headers:
{'Content-Type': 'application/json'}}});
但我得到“由于$http 和 $resource 请求的输入错误结束,没有内容映射到对象。
附加信息: * My client side application is running on Express serve with node.js
* 任何人都可以帮助我如何在上述任何方法中实现这一点吗?