title: how to get an array from controller to ajax function in laravel 4
body: <p>Hey there i'am using laravel 4 and i'am still beginner in all this.
  what i want to do is to get an array of data from my controller to my ajax function for helping me drawing my chart</p>
  
  <p>here is my controller function</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code> public function getAPI()
  
  
          $stats = DB::table('reponse')
              -&gt;groupBy('date')
              -&gt;orderBy('date', 'ASC')
              -&gt;remember(1440) 
              -&gt;get([
                  DB::raw('Date(created_at) as date'),
                  DB::raw('etatSatisfaction as value')
              ]);
  
          return $stats;
      }</code></pre>
  </div>
  </div>
  </p>
  
  <p>and this is my view i want to replace the static data with the data from my array</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script &gt;
  var chartData1 = [];
  
  
  generateChartData();
  
  function generateChartData() {
    var firstDate = new Date();
    firstDate.setDate(firstDate.getDate() - 500);
    firstDate.setHours(0, 0, 0, 0);
  
    for (var i = 0; i &lt; 500; i++) {
      var newDate = new Date(firstDate);
      newDate.setDate(newDate.getDate() + i);
  
      var a1 = Math.round(Math.random() * (40 + i)) + 100 + i;
      var b1 = Math.round(Math.random() * (1000 + i)) + 500 + i * 2;
  
  
      chartData1.push({
        date: newDate,
        value: a1,
        volume: b1
      });
    
    }
  }
  
  var chart = AmCharts.makeChart("chartdiv", {
    type: "stock",
      "theme": "none",
  
    dataSets: [{
        title: "first data set",
        fieldMappings: [{
          fromField: "value",
          toField: "value"
        }, {
          fromField: "volume",
          toField: "volume"
        }],
        dataProvider: chartData1,
        categoryField: "date"
      },
  
      
    ],
  
    panels: [{
  
        showCategoryAxis: false,
        title: "Value",
        percentHeight: 70,
  
        stockGraphs: [{
          id: "g1",
  
          valueField: "value",
          comparable: true,
          compareField: "value",
          balloonText: "[[title]]:&lt;b&gt;[[value]]&lt;/b&gt;",
          compareGraphBalloonText: "[[title]]:&lt;b&gt;[[value]]&lt;/b&gt;"
        }],
  
        stockLegend: {
          periodValueTextComparing: "[[percents.value.close]]%",
          periodValueTextRegular: "[[value.close]]"
        }
      },
  
      {
        title: "Volume",
        percentHeight: 30,
        stockGraphs: [{
          valueField: "volume",
          type: "column",
          showBalloon: false,
          fillAlphas: 1
        }],
  
  
        stockLegend: {
          periodValueTextRegular: "[[value.close]]"
        }
      }
    ],
  
    chartScrollbarSettings: {
      graph: "g1"
    },
  
    chartCursorSettings: {
      valueBalloonsEnabled: true,
          fullWidth:true,
          cursorAlpha:0.1
    },
  
    periodSelector: {
      position: "left",
      periods: [{
        period: "MM",
        selected: true,
        count: 1,
        label: "1 month"
      }, {
        period: "YYYY",
        count: 1,
        label: "1 year"
      }, {
        period: "YTD",
        label: "YTD"
      }, {
        period: "MAX",
        label: "MAX"
      }]
    },
  
    dataSetSelector: {
      position: "left"
    }
  });
  
  chart.addListener('rendered', function (event) {
      var dataProvider = chart.dataSets[0].dataProvider;
    $( ".amChartsPeriodSelector .amChartsInputField" ).datepicker({
        dateFormat: "dd-mm-yy",
        minDate: dataProvider[0].date,
        maxDate: dataProvider[dataProvider.length-1].date,
        onClose: function() {
            $( ".amChartsPeriodSelector .amChartsInputField" ).trigger('blur');
        }
    });
  });
  
  
  &lt;/script&gt;
  
      @stop</code></pre>
  </div>
  </div>
  </p>
  
  <p>Can anyone help please</p>