Hello, I'm trying to retrieve dates from the database based on a selection. If a user selects singer A for example, then I'm going through the database and get the unavailable dates of singer A.


Code:
var unavailableDates;

function unavailable(date) {
    dmy = date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear();
    if ($.inArray(dmy, unavailableDates) == -1) {
        return [true, ""];
    } else {
        return [false, "", "Unavailable"];
    }
}

$(document).ready(function()
{
    $("#datepicker").datepicker({
        dateFormat: 'yy-mm-dd',  
        beforeShowDay: unavailable,
        minDate: 0,
        firstDay: 1, // rows starts on Monday
        changeMonth: true,
        changeYear: true,
        showOtherMonths: true,
        selectOtherMonths: true,
        altField: '#date_due',
        altFormat: 'yy-mm-dd'
        });
        
    $('#datepicker').focus(function(){
        //alert($('#name').html());
         $.ajax({                                      
        url: 'getDates.php',                           
        data: "artist_id="+$('#name').html(),                        
        dataType: 'json',                     
        success: function(data)          
        {
           alert(data)
        }
        });
    })
    
});
Everything works fine. I used the "getDates.php" to retrieve the dates and pass them through the function. But how can I pass the "data" (within "success: function()") to the unavailable dates above? I get the dates from database but I don't know how to link them with the array "unavailableDates" (line 1) in order to show unavailable dates in datePicker.