I am trying to get some information from Database and make a chart with them. Unfortunately, the variables I use to store that values are losing their data outside of POST. completed and ongoing are assigned inside their POST methods, also each other's post methods, but not outside of it. When data2 executes, the variables become empty again. How can I fix this issue?
var completed;
var ongoing;
$.post(
"/api/EducationCompletionRates?status=1&startDate=20150701&endDate=20150705",
{ data: {} },
function (data) {
completed = data;
}
);
$.post(
"/api/EducationCompletionRates?status=2&startDate=20150701&endDate=20150705",
{ data: {} },
function (data) {
ongoing = data;
}
);
var data2 = [
{
value: completed,
color: "#46BFBD",
highlight: "#5AD3D1",
label: "Completed"
},
{
value: 700, //ongoing,
color: "#FDB45C",
highlight: "#FFC870",
label: "Ongoing"
}
]