I'm calling a function and I want to get back some value. But I didn't get any value.
How can I use the return value?
$(function () {
$(".datepicker").datepicker({
beforeShowDay: function (date) {
var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
return [array.indexOf(string) == -1]
console.log(array.indexOf(string) == -1);
}
});
});
var BDate = gateDateBooking(); // Calliing a function
var BookingDate = Bdate; // But i did't get any responce here
function gateDateBooking(){
$.ajax({
url: "localhost/CodeIgniter_2.2.0/index.php/admin/GetBookingDate",
type: "POST",
dataType: "text",
cache: false,
success: function (data) {
alert(data);
return data; // return responce
}
});
}
successcaller.gateDateBookingas a separate function.async: false. Learn how to work with async patterns. Reasons why outlined in answer below.