im using CI3 and jquery and i need to execute the getFechas(val) function not asynchronous .. so this is my code
$('#datepicker1').on('change', function() {
$.when(getFechas($('#datepicker1').val())).done(function(a1){
fechas = a1;
//console.log($('#datepicker1').val());
console.log(a1);
console.log(a1.slice());
});
});
and the ajax function
function getFechas(val){
var venc =[];
$.ajax({
type: "POST",
url: base_url+"index.php/admin/ajax_call/saldos",
data: {fecha: val},
success: function (data) {
var i =1;
$.each(data, function (key, value) {
venc[i] = value.fecha_vencimiento;
// console.log(value.fecha_vencimiento);
// console.log(value.comuna_id + ':' + value.comuna_nombre);
i++;
});
}
});
return venc;
}
I need to access to the array venc[]
....the return value of function ... and copy the value on fechas var (fechas is global empty array )