i'm trying to use fullCalendar's plugin in my symfony projet, but i have some trouble to insert data into database. i have a page calendar/index, where we can see the calendar, and the javascript to create an event etc.
my first approach was to do something simple. Insert the title of the event in database, for that i try this :
$.ajax({
type: "POST",
url: "calendar/data",
data: title,
dataType: 'script'
});
And now i would like to insert the title in my database with the executeData in actions.class.php, but the only way to insert data into database that i know is with form. My question is : Can i do something like that, and if yes, how insert data in the database ?
You have to grab in php the header sent to your php script:
First change this and try:
$.ajax({
type: "POST",
url: "calendar/data",
data: {title:'my title to insert'}, //data: title,
//dataType: 'script' remove this
});
In the beggining of your php script you should have this:
<?php
//Error Reporting -> You don´t need to have the next 4 lines, ignore them.
ini_set('display_errors', 1);
ini_set('log_errors', 1);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
error_reporting(E_ALL);
/*Try to fetch the title*/
if($_POST['title']){
var_dump($_POST['title']);
//You should see your title on top of the webpage or in network debug from chrome or firefox in XHR separator
}else{ echo "Crap no title"; }
?>
Also make sure your in the same domain, cross domain ajax requests are a pain...