title: How to pass a value from a popup form to a PHP page using JQuery & Ajax?
body: <p>It appears my question has been asked a couple of times before, yet I still can't seem to get my code to work - even though I believe I use the very same code as the solutions to those questions.</p>
  
  <p>So I am using the <a href="http://www.ericmmartin.com/projects/simplemodal/" rel="nofollow">SimpleModal JQuery plugin</a> to create a form in a popup window. This window contains the following HTML:</p>
  
  <pre><code>&lt;div id="containerInfo" class='modalPopUp' style='display:none'&gt;
          &lt;form id="frmContainerInfo" method="post" action="index.php"&gt;
              &lt;div style="border-bottom: 1px solid #000"&gt;
                  &lt;h1&gt;Test popup/h1&gt;
              &lt;/div&gt;
              &lt;br/&gt;
              &lt;div class='cargoInfoForm'&gt;
                      &lt;label class='cifLabel'&gt;Location:&lt;/label&gt;
                      &lt;select id="ddlLoc" name="ddlLoc" class="cifDDL" style="width: 130"&gt;
                          &lt;option value="Netherlands"&gt;Netherlands&lt;/option&gt;
                          &lt;option value="Paris"&gt;Paris&lt;/option&gt;
                          &lt;option value="Hongkong"&gt;Hongkong&lt;/option&gt;
                          &lt;option value="Tokyo"&gt;Tokyo&lt;/option&gt;
                      &lt;/select&gt;
                      &lt;br/&gt;
                      &lt;label class='cifLabel'&gt;Date:&lt;/label&gt;
                      &lt;input type="text" id="locDatePicker" name="locDatePicker" value="" class="cifInputField" style="width: 130"&gt;
                      &lt;br/&gt;
                      &lt;button id="saveLocInfo" name="buttonSubmitInfo" type="submit" class="cifSaveButton"&gt;Save&lt;/button&gt;
              &lt;/div&gt;
          &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Then I try to send the results of this form to my PHP page upon pressing the Save button in the popup window, so I can retrieve the value of the two fields (ddLock and locDatePicker). To do this I attempt to use JQuery and Ajax, which looks like this:</p>
  
  <pre><code>&lt;script&gt;
          $(document).ready(function() 
          {
               $(".editDisplay-button").click(function(){
                  $("#containerInfo").modal();
                  }); 
  
              $("#saveLocInfo").on("click", function(){
              var locval  = $("#ddlLoc").val();
              var dateval    = $("#locDatePicker").val();
              var locvalLen    = locval.length;
  
              if(locvalLen &lt; 4) {
                      $("#locval").addClass("error");
              }
  
              if(locvalLen &gt;= 4) {
          // if location lettercount is four or bigger
          $("#saveLocInfo").replaceWith("&lt;em&gt;sending...&lt;/em&gt;");
  
                  $.ajax({
                  type: 'POST',
                  url: 'container.php',
                  data: $("#frmContainerInfo").serialize(),
                  success: function(data) {
                                  var $response=$(data);
                                  alert($response.filter('#ddlLoc').text());   
                              }
                      });
  
  
                      }
                  });
              }); 
  
      &lt;/script&gt;
  </code></pre>
  
  <p>It appears the data I retrieve doesn't contain any values, because my alert doesn't show the location field value. Which I find odd considering I am mimicking working code of other people that had this problem. After this JQuery/Ajax code I try to access the values in my PHP file (though I believe I never retrieved the values to begin with), which looks like this:</p>
  
  <pre><code>&lt;?php
       $location = $_POST['ddlLoc'];
       $dateFieldValue = $_POST['locDatePicker'];
  
       echo ($location);
       echo ($dateFieldValue);
  ?&gt;
  </code></pre>
  
  <p>How can I get this to work, or alternatively, how can I retrieve the values of the input fields of my popup window's form in my PHP file?</p>
  
  <p>Thanks!</p>