2
我想從php獲取2維數組使用ajax和jquery。在PHP5.1.6上運行時獲取json是空輸出
的問題是,當我在php5.4.7運行它,我得到預期的JSON響應
[["A",46],["B",35],["C",68],["D",30],["E",27],["F",85]]
但隨着php5.1.6我得到的是json is null
的響應。我如何使它在PHP5.1.6中工作?
$.ajax({
type: "POST",
url: "get_data.php",
data: "",
dataType: "json",
success: function (json) {
var data = json;
initChart(data);
}
});
header('Content-Type: application/json');
$arr=array();
$arr = array(
array('A', 46),
array('B', 35),
array('C', 68),
array('D', 30),
array('E', 27),
array('F', 85),
);
echo json_encode($arr);
那麼有何使它在php5.1.6工作的解決方案? – nikhil 2013-03-25 05:54:07
Google。 http://www.boutell.com/scripts/jsonwrapper.html – 2013-03-25 05:55:11
@ user1814087查看編輯答案。 – 2013-03-25 05:56:38