I am sending some json data with ajax:
我正在用ajax发送一些json数据:
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:
它没有任何问题。Firebug控制台屏幕:
Soajax request is sending okay. Now I need to handle it.
Soajax请求发送正常。现在我需要处理它。
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:
这个代码显示了没有。看起来没有通过邮寄发送的数据。发送ajax请求的Firebug响应选项卡:
How I can handle json data in php file then?
那么如何在php文件中处理json数据呢?
1 个解决方案
#1
3
Json data does not receive in post.
Json数据不接受邮寄。
$json = file_get_contents('php://input');
$post = json_decode($json, TRUE);
echo __FILE__;
echo '<pre>';
var_dump($post);
echo '</pre>';
exit;
#1
3
Json data does not receive in post.
Json数据不接受邮寄。
$json = file_get_contents('php://input');
$post = json_decode($json, TRUE);
echo __FILE__;
echo '<pre>';
var_dump($post);
echo '</pre>';
exit;