I have a similar problem, it's been 3 days since I fought and nothing!
javascript code
var readUrlHome="/ Home / ReadGraphic /";
var barChartData;
function getJsonData(idIndicadores, idUgbs) {
$.getJSON(readUrlHome, { IdIndicador: idIndicadores, IdUGB: idUgbs }, function (data) {
barChartData = data;
});
}
var dataFromLoadData;
function loadData(idIndicadores, idUgbs) {
$.getJSON("/Home/LerGrafico/", { data:{ IdIndicador: idIndicadores, IdUGB: idUgbs }, format: "json" }).done(function (data) {
dataFromLoadData = data;
});
}
var dataFromLoadData02;
function LoadData02(idIndicadores, idUgbs) {
var property = this;
this.getingData = function () {
$.getJSON(readUrlHome, { IdIndicador: idIndicadores, IdUGB: idUgbs }, function (data) {
return data;
});
}
}
var dataFromLoadDataAjax;
function LoadDataAjax(idIndicadores, idUgbs) {
var datatoreturn;
$.ajax({
type: 'GET',
dataType: 'json',
url: '/Home/LerGrafico/',
data: { IdIndicador: idIndicadores, IdUGB: idUgbs },
success: function (data, msg) {
dataFromLoadDataAjax = data;
datatoreturn = data;
alert(msg)
}
});
return datatoreturn;
}
This last method displays an alert with msg of success.
The above examples do not work, in all of these examples the var declared before the method continues undefined, one of those methods there, whatever works, is called inside another function executed when I choose an item in a drop down list.
Any idea what I can do?
Editing:
I was able to get it right, instead of get json returning the result storing in a variable I put the javascript method that would make use of the requested data, had tried before but had given an error in a value among the data returned, when I stopped to check I realized it was a mistake to load this wrong value into chartjs. I thought the call was not working but the error was in the assembly of chartjs, after realizing that I changed the value and it worked.