title: Get Data Using Ajax Jquery and send Parameters to Controller
body: <p>I have a method that get data from database and show it on chart. Its working fine. Now, i need to put some filters on it, and I'm facing dificulties to pass my parameters to the controller.</p>
  
  <pre><code>$("#quadro").click(function () {
  
      Highcharts.setOptions({
          lang: {
              decimalPoint: ',',
              thousandsSep: '.'
          }
      });
  
      var data1 = $('#data1').val();
      var data2 = $('#data2').val();
      var empresa = $('#empresa option:selected').text();   
  
      $.ajax({
          url: 'Painel/QuadroReceitas',
          dataType: "json",
          type: "GET",
          contentType: 'application/json; charset=utf-8',
          data: { 'data1': data1, 'data2': data2, 'empresa': empresa },
          async: false,
          processData: false,
          cache: false,
          delay: 15,
          success: function (data) {
  
              var Categories = new Array();
              var FaturadoArray = new Array();
              var RecebidoArray = new Array();
              var AtrasadoArray = new Array();
  
              for (var i in data) {
                  Categories.push(data[i].Mes);
                  FaturadoArray.push(data[i].Receitas);
                  RecebidoArray.push(data[i].Recebido);
                  AtrasadoArray.push(data[i].Inad_Atual);
              }
  
              var MesArray = JSON.parse(JSON.stringify(Categories));
              quadroReceitas(MesArray, FaturadoArray, RecebidoArray, AtrasadoArray);
          },
  
          error: function (xhr) {
              alert('error');
          }
      });
  });
  
  
  function quadroReceitas(MesArray, FaturadoArray, RecebidoArray, AtrasadoArray) {
  
      var GlobalRotation = -90;
      var GlobalAlign = 'right';
      var X;
      var Y;
  
      var chart = new Highcharts.Chart({
          chart: {
              renderTo: 'container',
              type: 'column',
              realignLabels: true,
              animation: false
          },
  
          title: {
              text: 'Quadro de Receitas'
          },
  
          legend: {
              align: 'left',
              verticalAlign: 'top',
              floating: true,
              x: 0,
              y: 0
          },
  
          xAxis: {
              categories: MesArray,
              crosshair: true,
          },
  
          yAxis: {
              labels: { enabled: false },
              title: { enabled: false },
          },
  
          credits: {
              enabled: false
          },
  
          tooltip: {
              headerFormat: '&lt;span style="font-size:10px"&gt;{point.key}&lt;/span&gt;&lt;table&gt;',
  
              pointFormat: '&lt;tr&gt;&lt;td style="color:{series.color};padding:0"&gt;{series.name}: &lt;/td&gt;' +
                  '&lt;td style="padding:0"&gt;&lt;b&gt;{point.y:,.1f}&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;',
              footerFormat: '&lt;/table&gt;',
              shared: true,
              useHTML: true
          },
  
          plotOptions: {
              column: {
                  animation: true,
                  pointPadding: 0.05, // Defaults to 0.1
                  groupPadding: 0.05, // Defaults to 0.2
  
                  dataLabels: {
                      enabled: true,
                      rotation: GlobalRotation,
                      color: '#FFFFFF',
                      align: GlobalAlign,
                      verticalAlign: "top",
                      y: 10,
                      inside: false,
                      crop: false,
  
                      style: {
                          fontSize: '12px',
                          fontFamily: 'Verdana, sans-serif'
                      },
  
                      formatter: function () {
                          return Highcharts.numberFormat(this.y, 2);
                      }
                  }
              },
          },
  
          series: [
              { name: 'Faturado', color: '#004a91', data: FaturadoArray },
              { name: 'Recebido', color: '#009147', data: RecebidoArray },
              { name: 'Atrasado', color: '#FF0000', data: AtrasadoArray }
          ]
      });
  }
  </code></pre>
  
  <p>On Controller i have the code as bellow:</p>
  
  <pre><code>  [HttpGet]
          public JsonResult QuadroReceitas(string data1, string data2, string empresa)
          {
              if(empresa == "empresa" || empresa == null)
              {
                  empresa = "%";
              }            
  
              //Chave oChave = new Chave();
              DateTime agora = DateTime.Now;
              var start = new DateTime(agora.Year, agora.Month, 1).AddMonths(-11);
              var end = new DateTime(agora.Year, agora.Month, 1).AddMonths(1).AddDays(-1);
  
              if (data1 == null)
                  data1 = start.ToShortDateString();
  
              if (data2 == null)
                  data2 = end.ToShortDateString();
  
              ContasReceberData recData = new ContasReceberData();
              List&lt;ContasReceber&gt; receitas = new List&lt;ContasReceber&gt;();
  
              receitas = recData.GetQuadroReceitas(data1, data2, empresa)
                  .Select(o =&gt; new ContasReceber
                  {
                      Mes = o.Mes,
                      Receitas = Math.Round(o.Receitas,2),
                      Recebido = Math.Round(o.Recebido, 2),
                      Inad_Atual = Math.Round(o.Inad_Atual, 2)
                  }).ToList();
  
              return Json(receitas, JsonRequestBehavior.AllowGet);
          }  
  </code></pre>
  
  <p>As I told, it is working fine, but without the parameters:</p>
  
  <p>data1, data2, empresa</p>
  
  <p>I tried to change on AJAX to POST and Controller to HttpPost as i read in another topic but didnt work.</p>