title: How can I access ViewData in a PartialView from jQuery in MVC?
body: <p>I have a View loading a PartialView via jQuery. The PartialView has ViewData that the jQuery needs to access, but I can't seem to get to it from the jQuery. The code below uses the HighChart jQuery plugin (and it is just test code taken from the HighChart example page):</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
          var chart1; // globally available
          $(document).ready(function () {
              $('#reportButton').click(function (event) {
                  var actionUrl = '&lt;%= Url.Action("UserReport") %&gt;';
                  var customerId = $('#customersId').val();
                  var month = $('#monthsId').val();
                  var employees = '&lt;%= ViewData["Employees"] %&gt;'
                  alert(employees);
                  $.get(actionUrl, { customerId: customerId, month: month }, function (data) {
                      $('#result').html(data);
                      getHighChart();
                  });
              });
          });
  
          function getHighChart() {
              var employees = '&lt;%= ViewData["Employees"] %&gt;'
              alert(employees);
              chart1 = new Highcharts.Chart({
                  chart: {
                      renderTo: 'chart-container-1',
                      defaultSeriesType: 'bar'
                  },
                  title: {
                      text: 'Fruit Consumption'
                  },
                  xAxis: {
                      categories: [employees]
                  },
                  yAxis: {
                      title: {
                          text: 'Fruit eaten'
                      }
                  },
                  series: [{
                      name: 'Jane',
                      data: [1, 0, 4]
                  }, {
                      name: 'John',
                      data: [5, 7, 3]
                  }]
              });
          }
  
  
      &lt;/script&gt;
  </code></pre>
  
  <p>This jQuery is in the main view, because I don't know how I could put it in the PartialView with the document ready function. But by putting the call to the HighChart function in the callback of the get() function it works in the partial view. But accessing the ViewData doesn't...</p>
  
  <p>How can I achieve this? I need to get the data from the PartialView action method in order to populate the HighChart data...</p>