title: send data to php with jquery AJAX and retrieve the response
body: <p>I'm trying to do this:
  When a user click on the briefinfo div which has rows from mysqli, send the student id to id.php where the php file will then get all data by the student id and echo it out so i can use ajax to put it in my original index.php</p>
  
  <pre><code>&lt;script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js'&gt;&lt;/script&gt;    
  &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
      //in your Javascript, put
      $(document).ready ( function () {
      $("#briefinfo").click (function(){
      $.ajax({  
          type: 'POST',  
          url: 'id.php', 
          var studentid = "&lt;?php echo $studentid; ?&gt;";
          data: { id: studentid },
          success: function(response) {
                  $("#briefinfo").html(response);
              }
      });
      });
      });
          &lt;/script&gt;
  </code></pre>
  
  <p>Please help.
  This is the id.php</p>
  
  <pre><code>&lt;?php
  
      // connect to the database
      include('connect-db.php');
      // confirm that the 'id' variable has been set
      require_once("db.php");
          $id = $_POST['id'];
          if ($result = $mysqli-&gt;query("SELECT * FROM requests WHERE student_id=$id"))
          {
                  if ($result-&gt;num_rows &gt; 0)
                  {
                      echo "&lt;table border='1' cellpadding='10'&gt;";
                      echo "&lt;tr&gt;&lt;th&gt;Document #&lt;/th&gt;&lt;th&gt;Student #&lt;/th&gt;
                      &lt;th&gt;Documents needed&lt;/th&gt;&lt;th&gt;Edit&lt;/th&gt;&lt;th&gt;Delete&lt;/th&gt;
                      &lt;th&gt;recorded comment&lt;/th&gt;&lt;th&gt;unverify&lt;/th&gt;&lt;th&gt;comment&lt;/th&gt;&lt;th&gt;payment amount&lt;/th&gt;&lt;th&gt;set payment&lt;/th&gt;
                      &lt;/tr&gt;";
  
  
                          while ($row = $result-&gt;fetch_object())
                          {
                              echo "&lt;tr&gt;";
                              echo "&lt;td&gt;" . $row-&gt;id . "&lt;/td&gt;";
                              $studentid=$row-&gt;student_id;
                              echo "&lt;td&gt;&lt;a href='id.php?id=" . $row-&gt;student_id . "'&gt;$studentid&lt;/a&gt;&lt;/td&gt;";
                              echo "&lt;td&gt;" . $row-&gt;document . "&lt;/td&gt;";
                              echo "&lt;td&gt;&lt;a href='records.php?id=" . $row-&gt;id . "'&gt;Edit&lt;/a&gt;&lt;/td&gt;";
                              echo "&lt;td&gt;&lt;a href='delete.php?id=" . $row-&gt;id . "'&gt;Delete&lt;/a&gt;&lt;/td&gt;";
                              echo "&lt;td&gt;" . $row-&gt;comment . "&lt;/td&gt;";
                              echo "&lt;td&gt;&lt;a href='unverify.php?id=" . $row-&gt;id . "'&gt;unverify&lt;/a&gt;&lt;/td&gt;";
                              echo "&lt;td&gt;&lt;a href='comments.php?id=" . $row-&gt;id . "'&gt;comment&lt;/a&gt;&lt;/td&gt;";
                              echo "&lt;td&gt;" . $row-&gt;paymentamount . " pesos";"&lt;/td&gt;";
                              echo "&lt;td&gt;&lt;a href='paymentamount.php?id=" . $row-&gt;id . "'&gt;set amount&lt;/a&gt;&lt;/td&gt;";
                              echo "&lt;/tr&gt;";
                          }
                          echo"&lt;br&gt;&lt;br&gt;";
                          echo "&lt;/table&gt;";
                  }
                  else
                  {
                      echo "No results to display!";
                  }
          }
          else
          {
                  echo "Error: " . $mysqli-&gt;error;
          }
  
      ?&gt;
  </code></pre>