douluozhan4370 2014-05-13 11:39
浏览 40

JSON解码只读取PHP中的整数

I'm trying to read the query string (which is alphanumeric) on load the page using angular js and send it to php side. But somehow it reads only integer. Here is my code:

URL:

http://www.mydomain.com?token=5c1a45c

Angular JS Code:

App.controller('reset',['Auth','$scope','$location','$http',function (Auth,$scope,$location,$http) {
    $scope.init = function () {
        $scope.token = $location.search().token;
        $http.post('controller/reset.php',$scope.token).success(function(data){
                alert('success = '+data);
        }).error(function(e){
                alert('error in request');
        })
    }
    $scope.init();
}])

PHP Code:

<?php
$data = json_decode(file_get_contents("php://input"));->data;
echo '<pre>';print_r($data);
?>

I'm alerting the data coming from PHP and it comes success=5 while it should show me success=5c1a45c

I can't find the reason why it behaves like this while I'm using the same method to validate the login and works fine.

Can anyone please help me to fill the gap.

Thanks in advance.

  • 写回答

0条回答 默认 最新

    报告相同问题?