Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to load Google charts through a (jQuery)ajax call
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/8176352/trying-to-load-google-charts-through-a-jquery-ajax-call">Trying to load Google charts through a jQuery ajax call</a> </p> </blockquote> <p>I've been at this all day and cannot think of a way to make this work. I am not very familiar with jQuery.</p> <p>What I'm trying to do: I am trying to write a poll function that loads the results and displays it in the same page without refreshing.</p> <p>So far I have this jQuery code:</p> <pre><code> $("#post_yes").click(function(){ $("#result").html(ajax_load); //loads ajaxloader.gif $.post( "query.php", {answer: "yes", poll_id: 5}, function(responseText){ $.getScript(scriptUrl, function(){ $("#result").html(responseText); }); }, "html" ); }); </code></pre> <p>It's supposed to query query.php and insert the vote in the database. Then I've coded query.php to return the amount of yes and no values and then generate a chart on that page. This is something like that I have:</p> <pre><code> google.load('visualization', '1.0', {'packages':['corechart']}); // Load the Visualization API and the piechart package. google.setOnLoadCallback(drawChart); // Set a callback to run when the Google Visualization API is loaded. function drawChart() { // Create the data table. var data = new google.visualization.DataTable(); data.addColumn('string', 'Answers'); data.addColumn('number', 'Number'); data.addRows([ ['Yes', $yes_value], ['No', $no_value], ]); // Set chart options var options = { 'title' :'Do you Like my smile?', 'colors' :['#f25a5a','#5aa5f2'], 'fontName' :'Verdana', 'backgroundColor' :'#e7e7e7', 'chartArea' :{left:0,top:10,width:"400",height:"400"}, 'is3D' : true, }; var chart = new google.visualization.PieChart(document.getElementById('chart_div')); chart.draw(data, options); } </code></pre> <p>After debugging the page for a while using chrome's debugger I've noticed that any javascript in query.php does not run in my original page, and thats why the chart isn't being shown.</p> <p>My question to you gurus: Is there any way I can show the chart from query.php. Or is there a way I can show the chart after a user has voted (including the data the user has submitted)? What other approach can I take? </p> <p>Although I am not very fluent with JavaScript/JQuery, I will probably be able to follow any code (or even pseudo-code, any little bit helps!) you guys give.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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