0

I am trying to pre-populate fullcalendar based on the data being pulled from mysql via php. however, the event is not populating itself in fullcalendar. My code is:

 function invokeNewCal(elem)
 {
    var date = new Date();
        var d = date.getDate();
        var m = date.getMonth();
        var y = date.getFullYear();

        var calendar = $(elem).fullCalendar({
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,agendaWeek,agendaDay'
            },
            selectable: true,
            selectHelper: true
            editable: true,
            events: {
        url: 'index.php?methodname=getevents'
        }
        });

 }

The method is :

function getevents($m,$n)
{
    echo json_encode(array('title'=>'Hello','start'=>'Wed, 10 Apr 2013 13:00:00 IST','end'=>'Wed, 10 Apr 2013 17:00:00 IST'));
}

Ths JSON response is:

{"title":"Hello","start":"Wed, 10 Apr 2013 13:00:00 IST","end":"Wed, 10 Apr 2013 17:00:00 IST"}

However, the event is not being shown on fullCalendar. Any idea what am I missing?

Thanks

Full Req / Resp:

    Request URL:
    http://localhost/linkd/index.php?methodname=getevents&start=1364668200&end=1368297000&_=1365120846819

    Request Method:
    GET

    Status Code:
    HTTP/1.1 200 OK

    Request Headers
    05:44:26.000

  X-Requested-With:XMLHttpRequestUser-Agent:Mozilla/5.0 (Windows NT 6.1; rv:19.0) Gecko/20100101 Firefox/19.0Referer:http://localhost/linkd/schooladmin.phpHost:localhostConnection:keep-aliveAccept-Language:en-US,en;q=0.5Accept-Encoding:gzip, deflateAccept:application/json, text/javascript, */*; q=0.01

    Sent Cookie
    PHPSESSID:cs7ai8vreh43q9otaff91kpe67

    Response Headers
    Δ23ms

  X-Powered-By:PHP/5.3.21Server:Apache/2.2.21 (Win32) PHP/5.3.21Keep-Alive:timeout=5, max=99Date:Fri, 05 Apr 2013 00:14:26 GMTContent-Type:text/htmlContent-Length:95Connection:Keep-Alive

      Response Body
      Δ0ms

    {"title":"Hello","start":"Wed, 10 Apr 2013 13:00:00 EST","end":"Wed, 10 Apr 2013 17:00:00 EST"}
Satya
  • 8,693
  • 5
  • 34
  • 55
  • This is the conclusion I came up with. Maybe it will help you. http://stackoverflow.com/questions/13338817/fullcalendar-events-post-method-to-php-mysql/16412333#16412333 – Daniel Sloan Johnson May 07 '13 at 06:20

4 Answers4

1

Please change the timezone from IST to EST.

{
      "title":"Hello",
      "start":"Wed, 10 Apr 2013 13:00:00 EST",
      "end":"Wed, 10 Apr 2013 17:00:00 EST"
}

Following is the demo where we have two events one is in IST and another in EST, however the EST is only displayed.

DEMO

msapkal
  • 8,268
  • 2
  • 31
  • 48
  • are you sure that the ajax request for the given url is getting fire and it's returning the JSON response. – msapkal Apr 05 '13 at 02:08
1

I suggest using the ISO8601 standard specified in the documentation.
If you will go to the DEMO created by Mahesh Sapkal and change the dates there to the standard and both will appear.
The standard format is easy: YYYY-MM-DDTHH:mm:ss where the T is the delimiter between the the time and date.

Hope this helps

  • changed to ISO8601 as per the following response: {"title":"Hello","start":"2013-04-10T12:00:00","end":"2013-04-10T15:00:00"} however the event is not showing yet :) – Satya Apr 06 '13 at 15:20
  • You are missing the [] brackets. go to this [link](http://jsfiddle.net/beeeffective/AXtjr/) to see an example of the date you gave. – princeofchaos Apr 06 '13 at 19:09
  • You should put the json_encode data as an array inside an array like so: json_encrypt(array(array('title'=>'Hello','start'=>'2013-04-10T13:00:00','end'=>'2013-04-10T17:00:00'))); – princeofchaos Apr 06 '13 at 19:16
0

Hello,
I got the same issue and the solution is that you need to use events: JSON.parse(yourListOfEvents) else it won't work.

Hope it will help!

tomzi
  • 1,215
  • 1
  • 12
  • 23
0

Check doc, you have extra braces in events:{url:xxx}; but also in your json_response you are encoding only one event: you need an array of them.

MaxD
  • 574
  • 3
  • 10