Datepicker不可用日期(从数据库中检索的数据)

I'm trying to get dates from my database and put them in an array where it would be stored in json.

MAIN.PHP

$('#datepicker').focus(function(){
         $.ajax({                                      
        url: 'getDates.php',                   
        data: "artist_name="+$('#name').html(),         
        dataType: 'json',                     
        success: function(data)         
        {

        } 
        });
    })

getDates.php

$fullname = $_GET['artist_name'];
$result = mysql_query("SELECT .... FROM .... WHERE ... ='$fullname'")
$arraydates = array();
while($details = mysql_fetch_assoc($result)) {
      array_push($arraydates, $details['event_date']);   
}
echo json_encode($arraydates);

I've managed to put all the dates from the selected artist in the "arraydates".

I found this on google:

var unavailableDates = ["21-8-2013"];

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

That's fine. But now I'm trying to get the results from the array (within getDates.php) and use them in the "main.php". So basically I want to use the data like above with "unavailableDates" array. (and thus, disable the specific dates within the jquery date picker).

Instead of having "unavailableDates", I have the "arraydates". I don't really know how can I use my array inside the "unavailable" function.

I'm not really good with json, actually it's my first time I used json. So could anyone please help me with that?

you can use jquery:

//...
success: function(data){
    var arrayLength=data.length;
    for(var i=0;i<arrayLength;i++){
        if(unavailable(data[i]){
            //your code here
        }
    }
}
//...

The ajax will return $arraydates in a JSON format. Use parse.JSON(returned value) for example

success: function(data)         
    {
       var unavailableDates = parse.JSON(data);
       //Your code ....
    } 

Hope that helped.