0
votes

I have a problem with the events in my fullCalendar object not showing.

I have this JavaScript

  $('#calendar').fullCalendar({
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay'
    },
    editable: true,
    eventSources: ["api/apiCalendar"],
    loading: function (bool) {
        if (bool) $('#loading').show();
        else $('#loading').hide();

    }
});

I use asp.net mvc 4, web api to get the JSON

 public HttpResponseMessage Get(string start, string end)
    {
        calEvent e = new calEvent();
        e.id = 1;
        e.allDay = true;
        e.end = DateTime.Now;
        e.start = DateTime.Now.AddHours(-2);
        e.title = "Test";

        string json = JsonConvert.SerializeObject(e);

       return new HttpResponseMessage()
        {
            Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json")
        };
    }     

this method returns: {"title":"Test","allDay":true,"start":"2012-07-30T21:45:00.8461321+02:00","end":"2012-07-30T23:45:00.8461321+02:00","url":null,"id":1}

When I try to set this JSON string directly on the event, like this:

$('#calendar')......
events: [{"title":"Test","allDay":true,"start":"2012-07-30T21:45:00.8461321+02:00","end":"2012-07-30T23:45:00.8461321+02:00","url":null,"id":1}],

The event is rendering fine.

But when trying to fetch from the web method, nothing is showing. No errors or anything looking wrong when debugging.

I use the latest version off the plugin.

1

1 Answers

-1
votes

After more research the solution was here FullCalendar - JSON source doesn't work but using the JSON data directly does

It's the same problem with asp.net as pointed out in this post