この連想配列を JavaScript に渡そうとしています:
Array ( [0] => Array ( [topicid] => 38 [topic] => Dad ) [1] => Array ( [topicid] => 6 [topic] => What did you eat? ) [2] => Array ( [topicid] => 4 [topic] => What have you done? ) [3] => Array ( [topicid] => 43 [topic] => He ) [4] => Array ( [topicid] => 28 [topic] => I doubt it ) [5] => Array ( [topicid] => 10 [topic] => What made you feel good ) [6] => Array ( [topicid] => 12 [topic] => Say to yourself ) [7] => Array ( [topicid] => 29 [topic] => I doubt myself ) )
PHP ファイル内:
$topicsjson=json_encode($topics);
echo "<script>var topicsjson = $topicsjson; </script>";
JavaScript ファイル内:
document.write(topicsjson);
それは私にこの結果を与えます:
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
ここで何か不足していますか?