2014-03-14 154 views
1

我想发送一个JSON对象到我的web服务,它在请求数据中期待JSON。 这是我POST呼叫从angularJSAngular JS POST请求不发送数据

$http({method: 'POST', 
     url: 'update.htm', 
     data: $.param($scope.cover), 
     headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'} 
    }).success(function (data) { 
    // handle 
    }); 

价值覆盖对象

$scope.cover = {id:1, bean:{id:2}} 

荫越来越500 (InvalidPropertyException: Invalid property 'bean[id]' of bean class [BookBean]: Property referenced in indexed property path 'bean[id]' is neither an array nor a List nor a Map;)
在网络上,我们以这种方式发送

bean[id]:1 

我认为它应该像

发送
bean.id:1 

如何解决此问题。在此先感谢

+0

为什么要使用$ .PARAM如果你要发送的JSON数据? – BKM

回答

0

尝试张贴您的数据,如:

$http({method: 'POST', 
     url: 'update.htm', 
     data: $scope.cover, 
    }).success(function (data) { 
    // handle 
    }); 
+0

在服务器端,我得到了空值 – vivek