0

こんにちは、ajax、jqueryを使用してphpから2次元配列を取得しようとしていましたが、応答を取得できませんここに私のコードがあります

htmlコード

$.ajax({
            type: "POST",
            url: "get_data.php",
            data: "",
            dataType: "json",
            success: function (json) {
                var data = json.msg;

                initChart(data);
            }
        });

phpコード

header('Content-Type: application/json');

$responce=array();

for($i=0;$i<10;$i++)
{
  $responce[]=array($i,$j);
}

echo json_encode(array("msg"=>$responce));

しかし、Bugzilla でデバッグすると「json is empty」というメッセージが表示されます

4

2 に答える 2

0

多分これはあなたが意味するものですか?

for($i=0;$i<10;$i++) {
    for($j=0;$j<10;$j++) {
        $responce[]=array($i,$j);
    }
}
于 2013-03-23T11:19:19.113 に答える
0

これを試して :

$response = array();

for($i=0; $i<10; $i++) {
    $response[$i] = array();
    for($j=0; $j<10; $j++) {
        $response[$i][$j] = 10 * $i + $j;//Value is just an example. The important part is the left hand side of the assignment.
    }
}  
于 2013-03-23T12:11:44.600 に答える