Retrieving POST Data from AJAX Call to PHP
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_decode()
and access your attributes.
json_decode($data);
$post = file_get_contents('php://input');