Read associative array from json in $_POST

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

    You can avoid to use JSON.stringify and json_decode:

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

    And:

    
    

    Update:

    ... but if your really want to use them, then:

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

    And:

    page;
    ?>
    

提交回复
热议问题