未从php json源加载资源

未从php json源加载资源,php,mysql,json,fullcalendar,fullcalendar-scheduler,Php,Mysql,Json,Fullcalendar,Fullcalendar Scheduler,我正在创建一个调度web应用程序,并尝试从SQL数据库加载资源。它显示它正在运行我的php文件来检索资源,但它们都没有显示在日历上。我真的不知道为什么它们没有显示出来,我查看了fullcalendar的文档,在我看来,我是在遵守规则。有人知道为什么吗 以下是fullcalendar的代码: var calendar = $('#calendar').fullCalendar({ schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source'

我正在创建一个调度web应用程序,并尝试从SQL数据库加载资源。它显示它正在运行我的php文件来检索资源,但它们都没有显示在日历上。我真的不知道为什么它们没有显示出来,我查看了fullcalendar的文档,在我看来,我是在遵守规则。有人知道为什么吗

以下是fullcalendar的代码:

   var calendar = $('#calendar').fullCalendar({
    schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source',
    header:{
      left:'promptResource, prev, next, today',
      center:'title',
      right: 'month, agendaDay, timelineThreeDays, listDay'
    },
    views: {
      timelineThreeDays: {
        type: 'timeline',
        duration: { days: 3 },
        slotWidth: 75,
      }
    },
    businessHours: {
      dow: [1, 2, 3, 4, 5],
      start: "09:00",
      end: "17:00",
    },
    resources: "resourceGetScript.php",
    events: [
      { id: '1', resourceId: '1', start: '2017-04-05T10:00:00', end: '2017-04-05T11:00:00', title: 'event 1', doctor: 'Habib Habib'},
    ],
    defaultView: "timelineDay",
    minTime: "09:00",
    maxTime: "17:00",
    weekends: false,
    slotDuration: "01:00:00",
    allDaySlot: false,
    selectable: true,
    theme: true,
    contentHeight: 800,
    eventOverlap: false,
    resourceAreaWidth: "12%",
    slotWidth: 200,
    resourceLabelText: 'Rooms',
    select: function(start, end, allDay, jsEvent, view) {
      alert("test");
    },
    eventClick: function(calEvent, jsEvent, view){
      var myResource = calendar.fullCalendar('getEventResource', calEvent);
      myResource.title = "Change";
      calendar.fullCalendar('refetchResources');
      alert('Event: ' + calEvent.title + " " + calEvent.resourceId + " " + myResource.title);
    },
    resourceRender: function(resourceObj, labelTds, bodyTds){
      labelTds.on('click', function(){alert("clicked" + resourceObj.id + resourceObj.title);});
    }
  })
下面是resourceGetScript.php的代码,我在其中从数据库检索资源:

<?php
  session_start();
  include("includes/databaseHandler.inc.php");
  if(!isset($_SESSION['name'])){
    header("Location: ../index.php");
  }

  if($stmt = mysqli_prepare($conn, "SELECT * FROM rooms")){
    mysqli_stmt_execute($stmt);
    $result = mysqli_stmt_get_result($stmt);
    $resources = array();
    while ($row = mysqli_fetch_assoc($result)){
      $resourceArray['id'] = $row['id'];
      $resourceArray['title'] = $row['title'];
      $resources[] = $resourceArray;
    }

    echo json_encode($resources);
  }
 ?>

未充分使用FullCalendar的资源功能。但是为了消除这个问题,首先尝试使用以下文档在一些资源中硬编码:

您可以使用此演示手动构造资源并测试PHP文件:

如果工作正常,请在jscon\u encode($resources)之前运行resourceGetScript.php文件和print\r($resources),以确保资源结构正确。还可以使用mb\u detect\u encoding()检查文本格式,如果需要,使用mb\u convert\u encoding()转换为UTF-8

我希望这有助于您调试您的问题。很抱歉,我能给你一个直截了当的回答