I am trying to get a 2 dimensional array from php using ajax and jquery.
The problem is that when I run it in php5.4.7 I am getting the expected json response
[["A",46],["B",35],["C",68],["D",30],["E",27],["F",85]]
But with php5.1.6 i am getting a response that json is null. How can I make it work in 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);