Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>On Ajax Response Call drawChart() function again with new values. Below is the code which I have tried.</p> <p>Index file</p> <pre><code>&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() { alert('called'); var data = google.visualization.arrayToDataTable([['Company &amp; Model', 'Views'],['Samsung Hero Music E1232B',5],['Samsung Galaxy Y S5360',7],['Samsung Galaxy Ace S5830',7],['Karbonn K 1212',2],]); var options = { title: 'Most Popular Item ', hAxis: {title: 'Brand', titleTextStyle: {color: 'red'}}}; var chart = new google.visualization.ColumnChart(document.getElementById('MPI_chart_div')); chart.draw(data, options); } function drawChart2() { alert('called2'); var data = google.visualization.arrayToDataTable([['Company &amp; Model', 'Views'],['Samsung Music E1232B',5],['Samsung S5360',7],['Samsung S5830',7],['Karbonn K 1212',2],]); var options = { title: 'Most Popular Item ', hAxis: {title: 'Brand', titleTextStyle: {color: 'red'}}}; var chart = new google.visualization.ColumnChart(document.getElementById('MPI_chart_div')); chart.draw(data, options); } &lt;/script&gt; &lt;script&gt; var xmlHttp function MPI_set_shop(str) { alert(str); if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) { alert(xmlhttp.responseText); //google.load("visualization", str, {packages:["corechart"]}); //google.setOnLoadCallback(drawChart); drawChart2(); // Note down here.. } } xmlhttp.open("GET","chart.php?q="+str,true); xmlhttp.send(); } &lt;/script&gt; &lt;h3&gt;COLUMN CHART FOR MOST POPULAR ITEM &lt;/h3&gt; Select Shop &lt;select id="MPI_selected_shop" onchange="MPI_set_shop(this.value);"&gt; &lt;option value="all_Shops"&gt;All Shops&lt;/option&gt; &lt;option value="1"&gt;1&lt;/option&gt; &lt;option value="2"&gt;2&lt;/option&gt; &lt;option value="3"&gt;3&lt;/option&gt; &lt;option value="4"&gt;4&lt;/option&gt; &lt;/select&gt; &lt;input type="text" id="sd" /&gt; &lt;div id="MPI_chart_div" style="width: 800px; height: 400px;"&gt;&lt;/div&gt; </code></pre> <p>Note that I have created another function named drawChart2() but if you call drawChart() then also it will give you alert with "called". You just need to pass the new values in it. Hope above answer will help you. Most importantly I have done nothing except callback function. [Though I changed javascript ajax code but that wont be any issue.]</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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