全日历功能的AJAX

How can I add a ajax call into my viewRender?

For example:

var currentMonth = moment().month();

$('#calendar').fullCalendar({

    viewRender: function(view, element){
        url: '/getevents.php',
        type: 'POST', // ERROR LINE
        fail: function() {
            alert('There was an error while fetching events.');
        }
    }

});

the error I get is this:

Uncaught SyntaxError: Unexpected token :

how can i fix this?

Here's the solution:

First you need to make an AJAX call and since you're using jQuery, use $.ajax()

var currentMonth = moment().month();

$('#calendar').fullCalendar({

    viewRender: function(view, element){
      $.ajax({
        url: '/getevents.php',
        type: 'POST',
        success: function(response) {
          // SUCCESS CODE
        },
        // ERROR LINE
        error: function() {
          alert('There was an error while fetching events.');
        }
      });
    }

});

And about the error, that's because it is what it says. You're defining object properties inside a function with the wrong syntax.