Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/419.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我试图将日期的json对象响应数组添加到javascript中的数组中,并使用此数组在jquery日历中启用天_Javascript_Php_Jquery_Arrays_Json - Fatal编程技术网

我试图将日期的json对象响应数组添加到javascript中的数组中,并使用此数组在jquery日历中启用天

我试图将日期的json对象响应数组添加到javascript中的数组中,并使用此数组在jquery日历中启用天,javascript,php,jquery,arrays,json,Javascript,Php,Jquery,Arrays,Json,请注意,如果我直接将日期放入数组enabledDates中,它将起作用 var enabledDays = []; var answ = ''; function choosedoc(){ var xmlhttp = getXMLHttpRequest(); var actionmode = 1; var doctorid = document.getElementById('doctorid').value;

请注意,如果我直接将日期放入数组enabledDates中,它将起作用

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,
        });
    });

当我按下输入工具栏时,它将显示一个日历,除了数组中的日期之外,该日历将被禁用

如果使用jquery,为什么仍使用默认的xmlHttpRequest?为什么不仅仅是$.ajax呢?因为我使用xmlhttprequest来使用ajax从数据库检索日期……我知道对象的功能,但我要说的是,jquery为ajax请求提供了自己的函数集。