title: Sending javascript function with JSON is possible?
body: <p>I'm using <a href="http://www.highcharts.com/ref/" rel="nofollow">Highcharts</a> to display charts: when the document is ready an ajax request will fetch the data (JSON format) and initialize the <code>chart</code> object with some default data and some dynamic data (points):</p>
  
  <pre><code>$('document').ready(function() {
  
      var chart;
  
      $.ajax({
          url: "{{ path('stats_update') }}",
          type: "POST",
          dataType: "json",
          success: function(data){
              data.chart.renderTo = 'chart'; // id of the div element
              chart = new Highcharts.Chart(data); // inizialize chart object
          }
      });
  
  }); // end of document.ready
  </code></pre>
  
  <p>So far so good all works fine except when i have to send back some <strong>callbacks</strong>. It's not working and i can't find why. The chart "freezes" and no tooltip is displayed:</p>
  
  <p><strong>This is how the formatter function callback should be initialized (working):</strong></p>
  
  <pre><code>var chart = new Highcharts.Chart({
      tooltip: {
          formatter: function() { return this.x; }
  });
  </code></pre>
  
  <p><strong>This is how i send back the callback using JSON: Twig template engine outputting JSON, manually - no json_encode (not working):</strong></p>
  
  <pre><code>{
     "tooltip" : {
        "formatter" : "function() { return this.x; }"
     }
  }
  </code></pre>
  
  <p>There are no errors in JSON parsing with jQuery. I'd admin i'm not a javascript nor jQuery guru... thanks for helping.</p>