Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.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
Jquery 伊利兹_Jquery_Ajax_Fullcalendar_Fullcalendar Scheduler_Fullcalendar 3 - Fatal编程技术网

Jquery 伊利兹

Jquery 伊利兹,jquery,ajax,fullcalendar,fullcalendar-scheduler,fullcalendar-3,Jquery,Ajax,Fullcalendar,Fullcalendar Scheduler,Fullcalendar 3,更多信息请访问我已根据您的建议更新了代码。取出参考资料:['units.php']后,行并插入示例。我得到一个空白屏幕。我按照您上面的链接访问了这些文档,注意到他们使用了resourceObjects而不是resourcedata,这也不起作用。我会继续尝试的。我很抱歉我的代码没有意义我对js和FullCalendar非常陌生现在我可以让导航显示出来了,但是现在calendar。“注意到他们使用了resourceObjects而不是resourcedata”…如果您愿意,可以将回调参数命名为“s

更多信息请访问

我已根据您的建议更新了代码。取出参考资料:['units.php']后,行并插入示例。我得到一个空白屏幕。我按照您上面的链接访问了这些文档,注意到他们使用了resourceObjects而不是resourcedata,这也不起作用。我会继续尝试的。我很抱歉我的代码没有意义我对js和FullCalendar非常陌生现在我可以让导航显示出来了,但是现在calendar。“注意到他们使用了resourceObjects而不是resourcedata”…如果您愿意,可以将回调参数命名为“sjgdfjkghrkgw”,它们的工作方式和包含的内容没有区别,名称只是为了帮助开发人员,与任何其他变量一样。所以这不是问题所在。既然您提到了获取空白日历,您是否检查了浏览器控制台中的错误以确保没有出现语法错误或其他问题?您是否也验证了units.php实际上以正确的格式返回JSON?如果您不确定,请将该JSON添加到问题中。
        <!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<link href='../lib/fullcalendar.min.css' rel='stylesheet' />
<link href='../lib/fullcalendar.print.min.css' rel='stylesheet' media='print' />
<link href='../scheduler.min.css' rel='stylesheet' />
<script src='../lib/moment.min.js'></script>
<script src='../lib/jquery.min.js'></script>
<script src='../lib/fullcalendar.min.js'></script>
<script src='../scheduler.min.js'></script>
<script>

  $(function() { // document ready

    $('#calendar').fullCalendar({
      defaultView: 'agendaDay',

      editable: true,
      selectable: true,
      eventLimit: true, // allow "more" link when too many events
      header: {
        left: 'prev,next today',
        center: 'title',
        right: 'agendaDay,agendaTwoDay,agendaWeek,month'
      },
      views: {
        agendaTwoDay: {
          type: 'agenda',
          duration: { days: 2 },

          // views that are more than a day will NOT do this behavior by default
          // so, we need to explicitly enable it
          groupByResource: true

          //// uncomment this line to group by day FIRST with resources underneath
          //groupByDateAndResource: true
        }
      },

      //// uncomment this line to hide the all-day slot
      //allDaySlot: false,






refetchResourcesOnNavigate: true,
resources: function(callback, start, end, timezone) {


  $.ajax({
   url:"units.php",
   type:"POST",
   data:{ 
     start: start.format(),
     end: end.format(),
     timezone: timezone
   },
   success: function(resourceObjects) //define a variable to capture the JSON from the server
   {
     callback(resourceObjects); //return the new resource data to the calendar
   }
})},




      events: 'load.php',

select: function(start, end, allDay)
    {
     var title = prompt("Enter Event Title");
     if(title)
     {
      var start = $.fullCalendar.formatDate(start, "Y-MM-DD HH:mm:ss");
      var end = $.fullCalendar.formatDate(end, "Y-MM-DD HH:mm:ss");
      $.ajax({
       url:"insert.php",
       type:"POST",
       data:{title:title, start:start, end:end},
       success:function()
       {
        calendar.fullCalendar('refetchEvents');
        alert("Added Successfully");
       }
      })
     }
    },
    editable:true,
    eventResize:function(event)
    {
     var start = $.fullCalendar.formatDate(event.start, "Y-MM-DD HH:mm:ss");
     var end = $.fullCalendar.formatDate(event.end, "Y-MM-DD HH:mm:ss");
     var title = event.title;
     var id = event.id;
     var resourceId = event.resourceId;
     $.ajax({
      url:"update.php",
      type:"POST",
      data:{title:title, start:start, end:end, id:id, resourceId:resourceId},
      success:function(){
       calendar.fullCalendar('refetchEvents');
       alert('Event Update');
      }
     })
    },

    eventDrop:function(event)
    {
     var start = $.fullCalendar.formatDate(event.start, "Y-MM-DD HH:mm:ss");
     var end = $.fullCalendar.formatDate(event.end, "Y-MM-DD HH:mm:ss");
     var title = event.title;
     var id = event.id;
     var resourceId = event.resourceId;
     $.ajax({
      url:"update.php",
      type:"POST",
      data:{title:title, start:start, end:end, id:id, resourceId:resourceId},
      success:function()
      {
       calendar.fullCalendar('refetchEvents');
       alert("Event Updated");
      }
     });
    },

    eventClick:function(event)
    {
     if(confirm("Are you sure you want to remove it?"))
     {
      var id = event.id;
      $.ajax({
       url:"delete.php",
       type:"POST",
       data:{id:id},
       success:function()
       {
        calendar.fullCalendar('refetchEvents');
        alert("Event Removed");
       }
      })
     }
    },

   });
  });

</script>
<style>

  body {
    margin: 0;
    padding: 0;
    font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
    font-size: 14px;
  }

  #calendar {
    max-width: 99%;
    margin: 50px auto;
  }

</style>
</head>
<body>

  <div id='calendar'></div>

</body>
</html>
<?php

//load.php
$start = $_POST['start'];
$end = $_POST['end'];
$tz = $_POST['timezone'];

$connect = new PDO('mysql:host=localhost;dbname=', '', 'pass');

$data = array();

$query = "select s.*, u.unit_number from schedules s
          left join units u on u.id = s.unit where s.start_time like '$start%'";

$statement = $connect->prepare($query);

$statement->execute();

$result = $statement->fetchAll();
foreach ($result as $row) {
    /* Get Shift Start and calculate end time
      $start = date('G:i', $row['start_time']);
      $shift_lentgth = $row[''];
      $end= strtotime("+ $shift_lentgth", $start);
     */

    // Check unit level to give identifier

    $data[] = array(
        'id' => $row["id"],
        'title' => $row["unit_number"]
    );
}

echo json_encode($data);
?>
resources: "units.php"
refetchResourcesOnNavigate: true,
resources: function(callback, start, end, timezone) {
  $.ajax({
   url:"units.php",
   type:"POST",
   data:{ 
     "start": start.format(),
     "end": end.format(),
     "timezone": timezone,
   },
   success: function(resourceData) //define a variable to capture the JSON from the server
   {
     callback(resourceData); //return the new resource data to the calendar
   }
}
refetchResourcesOnNavigate: true,
  resources: '/my-resource-script.php'