我试图在javascript中添加一个json对象响应日期数组到一个数组并使用此数组,以便在jquery日历中启用日期

Note that if i directly put my dates into the array enabledDates, it will work.

var enabledDays = [];
    var answ = '';

    function choosedoc(){
        var xmlhttp = getXMLHttpRequest();  
        var actionmode = 1;
        var doctorid = document.getElementById('doctorid').value;


        xmlhttp.onreadystatechange=function(){

            if (xmlhttp.readyState==4 && xmlhttp.status==200)
            {
                var data = $.parseJSON(xmlhttp.responseText);

                var msg = data[0].message;

                if (msg != "") {
                    alert(decodeURIComponent(msg));
                } else { 
                    answ = data[0].some;
                    // this will get an array of dates: 11-11-2014,11-13-2014,11-14-2014
                    alert(enabledDays);
                    if(answ!=''){
                        alert(answ);
                        var result = answ.split(",");
                        //that would split the answer with the , seperator
                        for(i = 0; i < result.length; i++){
                            enabledDays.push("'"+result[i]+"'"); 
                        }
                    }else{
                        enabledDays ='';
                    }
                }
            }
        }
        xmlhttp.open("GET","appointments_ajax.php?actionmode="+actionmode+"&doctorid="+doctorid);
        xmlhttp.send();
    }

    function enableAll(date) {

        var m = date.getMonth() + 1, d = date.getDate(), y = date.getFullYear();
        for (i = 0; i < enabledDays.length; i++) {
            if($.inArray(m + '-' + d + '-' + y,enabledDays) != -1) {
                return [true]; 
            }
        }
        return [false];
    }

    $(function(){
        $('#appointmentdate').datepicker({
            dateFormat:'yy-mm-dd',
            beforeShowDay: enableAll,
        });
    });

When I press the input toolbar, it will display a calendar which will be all disabled except the dates that are in the array