title: Display Google Chart With jQuery From Partial View Asp.Net MVC
body: <p>I am using the Google charts to display the results of polls we are running. I use jQuery ajax call (GET) to call an ActionResult which submits their vote and then returns a partial view with a Google chart on.</p>
  
  <p>The google chart will not display when the HTML is loaded through jQuery but works fine when loaded as a normal RenderAction when the page loads.</p>
  
  <p>Can anybody shed some light, when loaded through jQuery are the neccessary scripts not loaded?</p>
  
  <p>Many thanks</p>
  
  <p>Sorry guys should have given more detail:</p>
  
  <pre><code>$.ajax({
  url: "Survey/RegisterAnswer",
  type: 'POST',
  data: {
    surveyQuestionId: surveyID,
    surveyAnswer: id
  },
  success: function (result) {
    alert(result);
    $('#survey-container').html(result).fadeIn("slow", function () {
    });
  }});
  </code></pre>
  
  <p>This is all working fine, and the Html is returned as I can see it in the alert, the partial view looks like this:</p>
  
  <pre><code>  &lt;script type="text/javascript" src="http://www.google.com/jsapi"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
    google.load('visualization', '1', { packages: ['corechart'] });
    &lt;%= Html.GoogleChart(ChartType.Pie, Model, "barChartDiv", Model.Data.First().Description, "Properties", "Total", 300, 250) %&gt;
  &lt;/script&gt;
  
  &lt;h3&gt;CHART&lt;/h3&gt;
  &lt;div id="barChartDiv"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The H3 header with text CHART displays fine but the google chart never displays.  This same partial view works fine if could when the page loads so it seems it's just when the google chart is called from jQuery.</p>
  
  <p>Any thoughts?  Many thanks.</p>