title: Pass Javascript variable to PHP via ajax
body: <p>I am trying to pass a variable from my javascript code over to the server side PHP code. I know this must be done via an ajax call which i believe i have done correctly, however accessing the variable i pass from my ajax into my php is when i run into trouble as i am new to php. Here is my code i have thus far:</p>
  
  <pre><code>$(document).ready(function() {
  
              $(".clickable").click(function() {
                  var userID = $(this).attr('id');
                  //alert($(this).attr('id'));
                  $.ajax({
                      type: "POST",
                      url: 'logtime.php',
                      data: "userID=" + userID,
                      success: function(data)
                      {
                          alert("success!");
                      }
                  });
              });
          });
  
  &lt;?php //logtime.php
  $uid = isset($_POST['userID']);
  //rest of code that uses $uid
  ?&gt;
  </code></pre>
  
  <p>I'm trying to pass my javascript variable "userID" to php ($userID), however i've gone wrong somewhere along the road. Thanks for the help!</p>