I am trying to send some Angular object through JSON.

I tried this.

$scope.dkPrintData=function(){
$scope.myData={name:'Ramesh',class:'XII',Marks:'90%'};
$http.get('dkStudnet.do?method=JsonData&Student='+ angular.toJson($scope.myData))
.success(function(data, status, headers, config) {

 });

If I removed % symbol in the $scope.MyData object it is working fine but it is not accepting special charters like %.

有帮助吗?

解决方案

'dkStudnet.do?method=JsonData&Student='+ encodeURIComponent(angular.toJson($scope.myData))
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top