Retrieving POST Data from AJAX Call to PHP

后端 未结 3 2075
我寻月下人不归
我寻月下人不归 2021-01-02 05:06

Three days had passed and still having problems to get this things work. This AJAX Call on my js file seems working when it comes to sending JSON data:

 var         


        
3条回答
  •  死守一世寂寞
    2021-01-02 05:42

    Can you see the ajax request data using the firebug console?

    You cannot get the lastname, firstname from $_POST. It's inside the json string. First, you have to get the data using

     $data = $_POST['data'] or $_REQUEST['data']
    

    Then, decode the $data using json_deocde and access your attributes.

    json_decode($data);
    

提交回复
热议问题