I have a function which returns data to getDates(), after processing i want the data in a global variable but it's not working.
var bookedDates=[];
function getDates(result) {
var bookedDates1=result.split(",");
var bookedDates2=[];
for(i=1;i<bookedDates1.length;i++){
bookedDates2.push(bookedDates1[i]);
}
bookedDates=bookedDates2;
}
alert(bookedDates);
$.ajax({
type: "POST",
url: "getbookeddates.php",
cache: false,
success: function(result){
getDates(result);
//dates booked
}
bookDates is blank in this case but it should be an array with ["21","22"].