Am trying to draw pie chart by getting data from sql server. The issue is that when I run the code I get error "Failed to load resource: the server responded with a status of 404 (Not Found)". The service is under ClientsService Here is my code
$(document).ready(function () {
$.ajax({
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
url: "/Clients/GetStoresCount",
data: "",
success: function(data){
chartData;
},
error: function(){
alert("Error Loading data! please try again.");
}
}).done(function (){
google.charts.setOnLoadCallback(drawChart);
});
});
function drawChart() {
var data =new google.visualization.DataTable();
data.addColumn('string','CityID');
data.addColumn('string','Stores');
for(var i = 0; i < chartData.length; i++){
if(i != 0){
data.addRow([chartData[i].CityID,chartData[i].Stores]);
}
}
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
draw(data, {title: "Stores Per region"});
chart.draw(data, options);
service for getting data from sql is:
public IEnumerable<Store> GetStoresCount()
{
using (IDbConnection conn = Connection)
{
string sQuery = "; exec GetStoreCountPerRejion";
var s = conn.Query<Store>(sQuery);
return s;
}
}