Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is one of the best examples I did which can help you : its tested and working nicely : Create two pages one called index.php and another one called get_json.php : This is not exactly the codes you posted but exactly the same idea and it answers the quetion.</p> <pre><code>the codes for index.php &lt;html&gt; &lt;head&gt; &lt;title&gt;King Musa Graph&lt;/title&gt; &lt;!-- Load jQuery --&gt; &lt;script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"&gt; &lt;/script&gt; &lt;!-- Load Google JSAPI --&gt; &lt;script type="text/javascript" src="https://www.google.com/jsapi"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; google.load("visualization", "1", { packages: ["corechart"] }); google.setOnLoadCallback(drawChart); function drawChart() { var jsonData = $.ajax({ url: "get_json.php", dataType: "json", async: false }).responseText; var obj = jQuery.parseJSON(jsonData); var data = google.visualization.arrayToDataTable(obj); var options = { title: 'King Musa' }; var chart = new google.visualization.LineChart( document.getElementById('chart_div')); chart.draw(data, options); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="chart_div" style="width: 900px; height: 500px;"&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; codes for get_json.php &lt;?php $data = Array (); $data [] = Array ("Name", "Value"); $data [] = Array ("PHP", 78); $data [] = Array ("JAVA", 1000); $data [] = Array ("HTML", 129); $table = json_encode($data); // header('content-type: application/json'); echo $table ; // this line is important it should be not disabled ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload