title: Form entries to query via PHP file and output result of PHP file using JQuery AJAX
body: <p>This is my html- simple form with two text inputs:</p>
  
  <pre><code>    &lt;div id="content"&gt;
        &lt;div id="options"&gt;
          &lt;form id="form1"&gt;
            &lt;table&gt;
              &lt;tr&gt;
                &lt;td&gt;Date:&lt;/td&gt;
                &lt;td&gt;&lt;input name="date" type="text" id="datepicker" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                &lt;td&gt;Size:&lt;/td&gt;
                &lt;td&gt;&lt;input name="size" type="text" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                &lt;td colspan="2"&gt;&lt;input name="submit" type="submit" value="Submit"/&gt;&lt;/td&gt;
              &lt;/tr&gt;
            &lt;/table&gt;
          &lt;/form&gt;
        &lt;/div&gt;
        &lt;div id="result"&gt; &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>And I'm trying to get the results of this form on submit to query a MySQL database '/details.php' and then output the results of the PHP file into the DIV 'result'.  I'm struggling on the passing the variables to the PHP file and outputting the results into the DIV.  I know I have to use some JQuery AJAX but I'm struggling to get it to work.</p>
  
  <p>This is my current AJAX script:</p>
  
  <pre><code>     &lt;script&gt;
      $('#form1').submit(function(e) {
          e.preventDefault(); // stops form from submitting naturally
          $.ajax({
              data: $(this).serialize(),
              url: '/details.php',
              success: function(response) {
                  $('#result').html(response); 
              }
          });
      });
      &lt;/script&gt;   
  </code></pre>
  
  <p>And on my PHP file im trying to aquire the variables with:</p>
  
  <pre><code>     $date=$_GET['date'];
       $size=$_GET['size'];
  </code></pre>
  
  <p>And then my connection to the database with SQL query and echoing out results.  Any suggestions to where I might be going wrong.  Thanks for the help!</p>