title: Passing variables to a page with AJAX and returning those variables in PHP
body: <p>I'm trying to do something I would think would be really simple:  Pass form data to a PHP page with AJAX, and get the result of the PHP back.</p>
  
  <p><strong>Edited to Add:</strong>  As written right now, it only returns successfully sporadically, rather than every time it's run, for some reason.</p>
  
  <p><strong>Edited to Add (05/30/2020):</strong></p>
  
  <p>I was able to get it working such as it is by changing the ajax like this:</p>
  
  <pre><code>&lt;script&gt;
                      $(document).ready(function(){
  
                          $("#button").click(function(){
  
                              var DDD_Number=$("#DDD_Number").val();
                              var Manager_Review=$("#Manager_Review").val();
                              var dataTosend='?DDD_Number='+DDD_Number+'&amp;Manager_Review='+Manager_Review;
                              $.ajax({
                                  type: "GET",
                                  url:'showme.php' + dataTosend,
                                  data:dataTosend,
                                  async: false,
                                success:function(data){
                                      document.getElementById('txtresponse').innerHTML = "Success.";
                                      document.getElementById('thisworks').innerHTML = data;
                                  },
                                  error: function(data){
                                     document.getElementById('txtresponse').innerHTML = "failure.";
                                 }
                              }); 
                          });
                      });
              &lt;/script&gt;
  </code></pre>
  
  <p>Now I have to work on serializing the form, because it's actually multiple rows I have to pass.  I don't know if I need that as a second question, though.</p>
  
  <p>This is my main page:</p>
  
  <pre><code>&lt;html&gt;
          &lt;head&gt;
              &lt;script src="Scripts/jquery.min.js"&gt;&lt;/script&gt;
              &lt;script src="Scripts/jquery-2.1.3.min.js"&gt;&lt;/script&gt;
              &lt;script type="text/javascript" src="Scripts/jquery.plugin.min.js"&gt;&lt;/script&gt;
              &lt;script type="text/javascript" src="Scripts/jquery.datepick.min.js"&gt;&lt;/script&gt;
              &lt;script&gt;
                      $(document).ready(function(){
  
                          $("#button").click(function(){
                              var DDD_Number=$("#DDD_Number").val();
                              var Manager_Review=$("Manager_Review").val();
                              var dataTosend='DDD_Number='+DDD_Number+'&amp;Manager_Review='+Manager_Review;
                              $.ajax({
                                  type: "POST",
                                  url:'showme.php',
                                  data:dataTosend,
                                  async: true,
                                 success:function(data){
                                     document.getElementById('txtresponse').innerHTML = "Success.";
                                     document.getElementById('thisworks').innerHTML = "Successful.";
  
                                 },
                                  error: function(data){
                                      console.log(data);
                                     document.getElementById('txtresponse').innerHTML = "failure.";
                                     console.log(data);
                                 }
                              });
                          });
                      });
              &lt;/script&gt;
          &lt;/head&gt;
      &lt;body&gt;
          &lt;form id="dddform" method="post"&gt;
              &lt;input type="text" id="DDD_Number" name="DDD_Number"&gt;&lt;br&gt;
              &lt;input type="text" id="Manager_Review" name="Manager_Review"&gt;&lt;br&gt;
              &lt;button id="button" name="Submit"&gt;Click Me&lt;/button&gt;
          &lt;/form&gt;
          &lt;div id="txtresponse"&gt;&lt;/div&gt;
          &lt;div id="thisworks"&gt;&lt;?php if(!isset($_POST['Submit'])){echo $Manager_Review;} ?&gt;&lt;/div&gt; 
  
              &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is showme.php:</p>
  
  <pre><code>&lt;?php
  
  $Manager_Review_Date = $_POST['Manager_Review'];
  
  echo $Manager_Review_Date;
  
  ?&gt;
  &lt;script language = 'Javascript'&gt;
      document.getElementById('thisworks').innerHTML = '&lt;?php echo $Manager_Review_Date; ?&gt;';
  &lt;/script&gt;
  </code></pre>
  
  <p>The call is made successfully.  (The "Success"and "Successful" messages appear), but I can't get the value of $Manager_Review_Date to appear in the "thisworks" DIV.</p>
  
  <p>Any pointers?  I'm fairly new to AJAX (if you couldn't tell from my code).</p>