1

I am sending some json data with ajax:

function send() {
    $.ajax({
        url: '/index.php?action=setShopOrdersGoods&order_id='+orderId,
        type: 'post',
        dataType: 'json',
        success: function (data) {
            $('#target').html(data.msg);
        },
        data: JSON.stringify(goods)
    });
}

There are no problems with it. Firebug console screen:

enter image description here

Soajax request is sending okay. Now I need to handle it.

How I can do this?

echo __FILE__;
echo '<pre>';
var_dump($_POST);
echo '</pre>';
exit;

This code shows nothing. Looks like there are no data send via post. Firebug response tab of sent ajax request:

enter image description here

How I can handle json data in php file then?

Community
  • 1
  • 1
Sharikov Vladislav
  • 7,049
  • 9
  • 50
  • 87

1 Answers1

3

Json data does not receive in post.

$json = file_get_contents('php://input');
$post = json_decode($json, TRUE);

echo __FILE__;
echo '<pre>';
var_dump($post);
echo '</pre>';
exit;
Samar Haider
  • 862
  • 10
  • 21