Read associative array from json in $_POST

前端 未结 6 941
后悔当初
后悔当初 2020-12-05 03:27

I am using jQuery to post a json object to my php application.

jQuery.post(\"save.php\",JSON.stringify(dataToSend), function(data){ alert(data); });
         


        
6条回答
  •  隐瞒了意图╮
    2020-12-05 03:31

    Try:

    echo $value->page;
    

    since json_decode's default behaviour is to return an object of type stdClass.

    Alternatively, set the second optional $assoc argument to true:

    $value = json_decode(stripslashes($_POST), true);
    echo $value['page'];
    

提交回复
热议问题