I want to get data array from php to Javascript. (Actually I am doing plotting using javascript library and the data is in the database: I get the data using php script and want to use that data for plotting). I have tried to use a JSON for this. My code looks follows but it is not working. Please give me a help on this
<script type="text/javascript">
<?php
$php_arr=array('abc','def'); // I want to transport this array to javascript
echo "display_diagram(" . json_encode($php_arr) . ")";
?>
function display_diagram(data) {
obj = JSON.parse(data); // this is not working for me