title: ASP.NET Core MVC AJAX call to Action method not working
body: <p>I am new to AJAX and I am trying to get some data from my controller method into my .js file so I can use that data in my chart.
  Everytime I run my project now I get the custom error message: "Error loading data! Please try again."
  So that means that it is getting inside the AJAX function, but not successfully. 
  Also I dont know how to debug this properly to see where it goes wrong.</p>
  
  <p>My .js code in a sepperate file is the following:</p>
  
  <pre><code>var chartData;
  
  $(document).ready(function () {
  $.ajax({
      url: "/Account/GetChartData",
      data: "",
      dataType: "json",
      type: "POST",
      contentType: "application/json; chartset=utf-8",
      success: function (data) {
          chartData = data.d.toString();
          alert("Data is: " + data.d.toString());
      },
      error: function () {
          alert("Error loading data! Please try again.");
      }
  }).done(function () {
      //After complete loading data
      drawChart();
  });
  });
  </code></pre>
  
  <p>My controller method looks like this:</p>
  
  <pre><code>public static object[] GetChartData()
      {
          var chartData = new object[2];
  
          //Manually adding some test data
          chartData[0] = new object[]
          {
              "Day",
              "Detected Asparaguses",
              "String Operations",
              "Successful Sting Operations"
          };
          chartData[1] = new object[]
          {
              "21-09-2018",
              100,
              85,
              80
          };
          return chartData;
      }
  </code></pre>