且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

角JS POST请求不发送JSON数据

更新时间:2023-01-17 08:04:24

如果您在您的序列化的数据对象,它不会是一个正确的JSON对象。就拿你所拥有的,只是包装数据对象在 JSON.stringify()

If you are serializing your data object, it will not be a proper json object. Take what you have, and just wrap the data object in a JSON.stringify().

$http({
    url: '/user_to_itsr',
    method: "POST",
    data: JSON.stringify({application:app, from:d1, to:d2}),
    headers: {'Content-Type': 'application/json'}
}).success(function (data, status, headers, config) {
    $scope.users = data.users; // assign  $scope.persons here as promise is resolved here 
}).error(function (data, status, headers, config) {
    $scope.status = status + ' ' + headers;
});