title: JQuery / AJAX: On Input Field change, create php session, and refresh current page
body: <p>I have two input fields.  One is for show called business and the other is hidden called auto_search_id and goes to server.  I have already created an autocomplete functionality.  What I want to do is if the user starts typing and decides to click on an autocomplete list item which has already stored businesses, the page takes the id, sends it to update.php page to update the PHP Session id, and then refreshes the page with the current Session id.</p>
  
  <p>Having problems figuring out the correct AJAX coding. My change function for the input field is not working.  It pulls up the autocomplete, but when an auto complete list item is clicked, it doesn't send the id and refresh a page. I still new to JQuery/AJAX, but think I am missing something in the on #auto_search_id change function but not knowing what.  Please Help... </p>
  
  <p>Javascript / JQuery / Ajax  </p>
  
  <pre><code>    &lt;script&gt;
          $(document).ready(function(){
              $("#business").autocomplete({
                  minLength: 2,
                  source: function(request, response){
                      $.ajax({
                          type: "POST",
                          url: "/autocomplete-pq.php",
                          dataType: "json",
                          data:'keyword=' + request.term,
                          success: function(data){
                              response(data);
                          }
                      });
                  },
                  select: function(event, ui){
                      $("#business").val(ui.item.label);
                      $("#auto_search_id").val(ui.item.value);
                      return false;
                  }
              });
  
              $("#auto_search_id").change(function(){
                  $.ajax({
                      type:'POST',
                      url:"/update.php",
                      data: { varname: reponse},
                      success:function(response){
                          location.reload()
                      }
                  });             
              });
          });
  
      &lt;/script&gt;
  </code></pre>
  
  <p>PHP</p>
  
  <pre><code>    &lt;?php
          session_start();
          $_SESSION["id"] = $_POST["varname"];
          echo $_SESSION["id"];
      ?&gt;
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code>    &lt;input type="text" id="business" name="jurisdiction" value="&lt;?php echo $juristiction ?&gt;" required&gt;
      &lt;input type="hidden" name="search" id="auto_search_id"  /&gt;  
  </code></pre>