[Chartjs]-Not able to pass array in chart js with ajax

1👍

You are using async code but expecting it to work like sync code. When you call new Chart all the arrays are still empty. So you will need to adjust the chart directly in your ajax and not the original variables or create the chart in your ajax

$.ajax({
   url : "../controllers/getCategoryNames.php",
   method :"GET",
   success: function(data){
      let categoryData = JSON.parse(data);
      for(let i in categoryData){
         myChartOne.data.labels.push(categoryData[i].category_name);
      }
      myChartOne.update();
   }
})

Leave a comment