无法读取null javascript的属性“ split”

时间:2019-07-16 12:35:54

标签: javascript mongodb

我正在尝试设置cron,但它告诉我Google chrome控制台中的拆分存在错误,我花了一周的时间来解决该错误

这将jquery 2.1.3与mongo数据库一起使用

function doWork(){
    makeCall('data/getSchedule.php','',function(err,res){
        var lastMovedDay= res.lastDay;
        var lastExecDay= res.lastExec;
        if($("input[name=tipo]:checked").val()=="especifico"){
            var _firstExec= $('#1Ejecucion').val();
            var _dayExec= $('#diaEjecucion').val();
            var arrayDate= _firstExec.split('-');
            var _hour= $("#horaEspecifica").val();
            var _begin= $("#diaDesde").val();
            var _end= $("#diaHasta").val();
            var date= new Date(arrayDate[0], (arrayDate[1]-1), arrayDate[2]);
            var arrayLastExec=lastMovedDay.split('-');
            var lastDate= new Date(arrayLastExec[0], arrayLastExec[1]-1, arrayLastExec[2]);
            lastDate.setDate(lastDate.getDate() + 7);
            if(_dayExec==days[date.getDay()]){
                if(lastDate<=date){                 
                    params = {
                        dayExec:_dayExec,
                        hour:_hour,
                        firstExec:_firstExec,
                        begin:_begin,
                        end:_end
                    }
                    makeCall('data/guardarCalendarizacion.php',params,function(err,res){
                        alert("Calendarización Actualizada");
                    });
                }
                else{
                    alert("La fecha de primera ejecución debe ser mayor al  "+ lastDate.toISOString().slice(0, 10));
                }
            }
            else{
                alert("El día de primera ejecución debe ser un "+ $('#diaEjecucion').val());
            }
        }
        else{
            var _hour= $("#horaRecurrente").val();
            var _rec=parseInt($("#diasRec").val());
            var today= new Date();
            today.setHours(0,0,0,0);
            var arrayLastDay=lastMovedDay.split('-');           
            var lastDate= new Date(arrayLastDay[0], arrayLastDay[1]-1, arrayLastDay[2]);
            lastDate.setDate(lastDate.getDate()+1);
            var limitMin= new Date(today);          
            limitMin.setDate(limitMin.getDate() - _rec);            
            var limit= new Date(today);
            limit.setDate(limit.getDate() -1);
            var next= new Date(today);
            next.setDate(next.getDate() + _rec-1);
            console.log(_rec+ " "+limitMin + " "+ lastDate);
            var save= true;
            if(limitMin>lastDate){
                console.log("mayor");
                limitMin.setDate(limitMin.getDate()-1);
                var r = confirm("Los tiempos del rango "+ lastDate.toISOString().slice(0, 10)+" - "+limitMin.toISOString().slice(0, 10)+ " no se va trasladar. \n ¿Desea Guardar la calendarización?");
                if (!r) {
                    save=false;
                }           
            }
            if(save){
                params = {
                    hour:_hour,
                    rec:_rec
                }
                makeCall('data/guardarCalendarizacion.php',params,function(err,res){
                    alert("Calendarización Actualizada");
                });
            }
        }
    });
}

错误在以下几行中:** var array Date = _first Exec.split('-'); ** ** var arrayLastExec = lastMovedDay.split('-'); ** ** var arrayLastDay = lastMovedDay.split('-'); **

数据来自文件GetSchudele.php,它正在尝试连接到集合,但没有带来任何东西,当我尝试保存它并没有保存我时,错误仍然存​​在于分割中

<?php 
require_once('data.php');
header('Content-Type: application/json; charset=UTF-8;');
//config
$dbhost = $hostname;
$dbname = $database;

//connection
$m = new MongoClient("mongodb://$dbhost");
$db = $m -> $dbname;

//selecting collection
$calendario = $db->ejecucion;

$result = $calendario->findOne();
if($result['recurrence']){
    $return = array(
        'recurrence'=>true,
        'rec'=>$result['period'],
        'hour'=>$result['hour'],
        'min'=>$result['min'],
        'lastExec'=>$result['last_execution'],
        'lastDay' =>$result['last_day']
    );
}
else{
    $return = array(
        'recurrence'=>false,
        'dayExec'=>$result['day_week'],
        'hour'=>$result['hour'],
        'min'=>$result['min'],
        'lastExec'=>$result['last_execution'],
        'firstExec'=>$result['first_execution'],
        'begin'=>$result['range']['start'],
        'end'=>$result['range']['end'],
        'lastDay' =>$result['last_day']
    );
}

echo json_encode($return, JSON_UNESCAPED_UNICODE);


?>

0 个答案:

没有答案