$.post("index.php",{news_count: 20},function(data){$("#name").html(data.count);},"json");
<?php
$news["count"] = $_POST["news_count"];
echo json_encode($news);
?>
$.post("index.php",{news_count: 20},function(data){$("#name").html(data.count);},"json");
<?php
$news["count"] = $_POST["news_count"];
echo json_encode($news);
?>
你怎么知道为空呢? 说不定请求都没发送,前面的代码报错了什么的。。自己f12打开浏览器开发工具看控制台报什么错误,ajax返回了什么
你的$news对象存在没有先。