fathaahansar fathaahansar - 1 year ago 75
JSON Question

Giving FullCalendar the json feed url based on a data from html select value

Here I'm trying to customize the json feed url that is usually given. I want to add an input data as a GET request to the php file events.php

The script:

function eventcaller() {
events: 'events.php?room='+$( "#room_num" ).find( "option:selected" ).prop("value"),

header: {
left: 'prev,next,today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
defaultView: 'agendaWeek'


$room_num = $_GET['room_num'];
//I do queries and get an associative events array exactly the way fullcalendar likes it
echo json_encode($events);


<select class="select form-control" id="room_num" name="room_num" onchange="eventcaller()">
<option value="0">Select a room</option>
<option value="1">1</option>
// and so on.

I get the following error in the console:

Uncaught ReferenceError: eventcaller is not defined

Pointing to the html select tag where I mentioned onchange.

I don't understand what is my mistake here. If there is an alternate method to get my job done, I'll be more than happy. Thanks in advance.


This solved the issue for me with my PHP grabbing the POST variable dynamicValue.

    events: {
        url: "/myfeed",
        data: function() {
            return {
                dynamicValue: $("#dropdownList").val()
        type: "POST"
    $("#dropdownList").change(function () {

This question was asked before, so here it is jquery fullcalendar send custom parameter and refresh calendar with JSON