Read associative array from json in $_POST

前端 未结 6 934
后悔当初
后悔当初 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:54

    $_POST will not be populated if the request body is not in the standard urlencoded form.

    Instead, read from the read-only php://input stream like this to get the raw request body:

    $value = json_decode(file_get_contents('php://input'));
    

提交回复
热议问题