title: Passing a value to PHP from jQuery Ajax
body: <p>I'm trying to get a value back to PHP which I can work with and send to the database. I don't seem to be able to do that using the GET type of jQuery AJAX. Here's the PHP I'm using to catch the value:</p>
  
  <pre><code>&lt;?php require_once("header.php"); ?&gt;
  &lt;?php require_once("class.php"); ?&gt;
  &lt;?php
  
  //$month = $_POST['month'];
  //$year = $_POST['year'];
  
  $month = 8;
  $year = 2013;
  $numDays = cal_days_in_month(CAL_GREGORIAN, $month, $year);
  $empty = "&lt;table class='box'&gt;&lt;td&gt;&amp;nbsp&lt;/td&gt;&lt;/table&gt;";
  
  $cal = new calendar();
  $cal-&gt;mkMonth($month);
  $cal-&gt;emptyDays($empty, $numDays, $month, $year);
  $cal-&gt;mkdays($numDays, $month, $year);
  
  echo "&lt;/div&gt;";
  
  
  echo "&lt;div id='jresult'&gt;";
  if (isset($_GET['id'])) {
     echo ($_GET['id']);
  }
  
  echo "&lt;/div&gt;";
  ?&gt;
  </code></pre>
  
  <p>Here's the jQuery...</p>
  
  <pre><code>$(document).ready(function(){
      $(".box").mouseenter(function(){$(this).css("background-color", "red");});
      $(".box").mouseout(function(){$(this).css("background-color", "transparent");});
      $(".box").click(function() {
          date_time = $(this).attr('id');
          console.log(date_time);
          $.ajax({
              type: 'GET',
              url: '/book.me/loop.php',
              data: "id=" + $(date_time).val(),
              success: function(data){
                  alert('successful');
              }
          });
      });
  });
  </code></pre>
  
  <p>I'm trying to pass in the id of the <code>.box</code> class element to the <code>date_time</code> variable which works, but it doesn't seem to be working when I call <code>$_GET['id']</code> in PHP. I'm just getting an undefined value back.</p>