Question

I am trying to generate some JSON to store information about calendar events for use in the fullCalendar jQuery plugin. The plugin documentation provides that the calendar is able to fetch events from a JSON feed:

$('#calendar').fullCalendar({

eventSources: [

    // your event source
    {
        url: '/myfeed.php', // use the `url` property
        color: 'yellow',    // an option!
        textColor: 'black'  // an option!
    }

    // any other sources...

    ]

});

My question is: Where does the myfeed.php file go if I am using CodeIgniter? If I put the file off the root of the site as in http://mysite/myfeed.php then I am not able to query the database, presumably because the file is outside of the CodeIgniter application folder. If the myfeed.php file needs to be inside the CodeIgniter application folder, then where does it go and how do I modify the URL parameter above to reflect the new location?

Thanks

Was it helpful?

Solution

One way to do is to create a controller for AJAX calls and put all of your ajax functions in there. So in your example, in your controller folder, you would create a controller file called ajax.php and add a "function myfeed()" method. Then, if your javascript is in a php file your URL would be 'ajax/myfeed'. If it's not in a php file, then you'll have to pass in the base_url() (see http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html) to your .js file so that the URL is correct.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top