title: I would like to get an id from the database in a jquery dialog
body: <p>I would like to get an id from the database in a jquery dialog. Im using fullcalendar and when i click on an event a dialog opens. Currently its empty but i would like to get the id of the event and show this in the dialog.</p>
  
  <p>Fullcalendarextern.js:</p>
  
  <pre><code>    $(document).ready(function() {
    var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();
  
    var calendar = $('#calendar').fullCalendar({
     editable: true,
     header: {
      left: 'prev,next today',
      center: 'title',
      right: 'month,agendaWeek,agendaDay'
     },
  
     events: "../testcalendar/fullcalendar/events.php",
  
  
  
     // Convert the allDay from string to boolean
     eventRender: function(event, element, view) {
      if (event.allDay === 'true') {
       event.allDay = true;
      } else {
       event.allDay = false;
      }
     },   
     selectable: true,
     selectHelper: true,
     select: function(start, end, allDay) {
     var title = prompt('Event Title:');
     if (title) {
     var start = $.fullCalendar.formatDate(start, "yyyy-MM-dd HH:mm:ss");
     var end = $.fullCalendar.formatDate(end, "yyyy-MM-dd HH:mm:ss");
     $.ajax({
     url: '../testcalendar/fullcalendar/add_events.php',
     data: 'title='+ title+'&amp;start='+ start +'&amp;end='+ end ,
     type: "POST",
  
     });
     calendar.fullCalendar('renderEvent',
     {
     title: title,
     start: start,
     end: end,
     allDay: allDay
     },
     true // make the event "stick"
     );
     }
     calendar.fullCalendar('unselect');
     },
      editable: true,
     eventDrop: function(event, delta) {
     var start = $.fullCalendar.formatDate(event.start, "yyyy-MM-dd HH:mm:ss");
     var end = $.fullCalendar.formatDate(event.end, "yyyy-MM-dd HH:mm:ss");
     $.ajax({
     url: '../testcalendar/fullcalendar/update_events.php',
     data: 'title='+ event.title+'&amp;start='+ start +'&amp;end='+ end +'&amp;id='+ event.id ,
     type: "POST",
  
     });
     },
     eventResize: function(event) {
     var start = $.fullCalendar.formatDate(event.start, "yyyy-MM-dd HH:mm:ss");
     var end = $.fullCalendar.formatDate(event.end, "yyyy-MM-dd HH:mm:ss");
     $.ajax({
      url: '../testcalendar/fullcalendar/update_events.php',
      data: 'title='+ event.title+'&amp;start='+ start +'&amp;end='+ end +'&amp;id='+ event.id ,
      type: "POST",
  
     });
  
  },
  eventClick: function(calEvent, jsEvent, view) {
  $( "#dialogstatusevent" ).dialog({
        autoOpen: false,
  
      });
  
        $( "#dialogstatusevent" ).dialog( "open" );
          var id = $("#idtest").val();
      },
  
     eventMouseover: function(event, domEvent) {
                  var layer = '&lt;div id="events-layer" class="fc-transparent" style="position:absolute; width:100%; height:100%; top:-1px; text-align:right; z-index:100"&gt;&lt;a&gt;&lt;img src="../testcalendar/editbt.png" title="edit" width="14" id="edbut'+event.id+'" border="0" style="padding-right:3px; padding-top:2px;" /&gt;&lt;/a&gt;&lt;a&gt;&lt;img src="../testcalendar/delete.png" title="delete" width="14" id="delbut'+event.id+'" border="0" style="padding-right:5px; padding-top:2px;" /&gt;&lt;/a&gt;&lt;/div&gt;';
                  $(this).append(layer);
                  $("#delbut"+event.id).hide();
                  $("#delbut"+event.id).fadeIn(300);
                  $("#delbut"+event.id).click(function() {
                  $.ajax({
                  url: '../testcalendar/fullcalendar/delete_events.php',
                  data: 'id=' + event.id ,
                  type: "POST",
                  });
                  var nTime = 1 * 50;
                  window.setTimeout("location.reload()", nTime);
                  });
                  $("#edbut"+event.id).hide();
                  $("#edbut"+event.id).fadeIn(300);
                  $("#edbut"+event.id).click(function() {
                      var title = prompt( '\n\nNew Event Title: ');
  
                      if(title){
                  $.ajax({
                  url: '../testcalendar/fullcalendar/update_title.php',
                  data: 'title='+ title+'&amp;id='+ event.id ,
                  type: "POST",
                  });
                  var nTime = 1 * 50;
                  window.setTimeout("location.reload()", nTime);
                      }
  
  
                  });
              },   
  
              eventMouseout: function(calEvent, domEvent) {
                  $("#events-layer").remove();
              },
  
  
    });
  
   });
  </code></pre>
  
  <p>agenda_view.php:</p>
  
  <pre><code>&lt;div id="content"&gt;
  &lt;div id="table-row"&gt;
  &lt;!-- &lt;div class="header_title" style="margin-bottom: 10px;"&gt;Agenda&lt;/div&gt; --&gt;
   &lt;div class="agenda"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;link href='&lt;?=base_url();?&gt;testcalendar/css/fullcalendar.css' rel='stylesheet' /&gt;
  &lt;script src='&lt;?=base_url();?&gt;testcalendar/js/jquery-1.9.1.min.js'&gt;&lt;/script&gt;
  &lt;script src='&lt;?=base_url();?&gt;testcalendar/js/jquery-ui-1.10.2.custom.min.js'&gt;&lt;/script&gt;
  &lt;script src='&lt;?=base_url();?&gt;testcalendar/js/fullcalendar.min.js'&gt;&lt;/script&gt;
  &lt;script src='&lt;?=base_url();?&gt;testcalendar/js/fullcalendarextern.js'&gt;&lt;/script&gt;
  &lt;script src='&lt;?=base_url();?&gt;testcalendar/js/nieuweafspraak.js'&gt;&lt;/script&gt;
  &lt;link href="&lt;?=base_url();?&gt;testcalendar/assets/css/jquery-ui-1.10.0.custom.css" rel="stylesheet" type="text/css" /&gt;
  
  &lt;style&gt;
  
   body {
    margin-top: 40px;
  
    }
  
  
   #calendar {
    width: 900px;
    margin: 0 auto;
    }
  
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="dialogstatusevent" style="display:none" title="Mijn afspraak"&gt;
  &lt;div id="idtest"&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div id='calendar'&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>events.php:</p>
  
  <pre><code>&lt;?php
  // List of events
   $json = array();
  
   // Query that retrieves events
   $requete = "SELECT * FROM evenement ORDER BY id";
  
   // connection to the database
   try {
   $bdd = new PDO('mysql:host=localhost;dbname=blackboks-calendar', 'root', 'root');
   } catch(Exception $e) {
    exit('Unable to connect to database.');
   }
   // Execute the query
   $resultat = $bdd-&gt;query($requete) or die(print_r($bdd-&gt;errorInfo()));
  
   // sending the encoded result to success page
   echo json_encode($resultat-&gt;fetchAll(PDO::FETCH_ASSOC));
  
  ?&gt;
  </code></pre>