title: Using a value from an Input, do a Select using that value, then return a json to an autocomplete
body: <p>I'm new to Json, Ajax and Jquery, so this is turning out very frustrating.
  I'm doing a code to autocomplete on a form using Jquery. My form consists in 4 elements:</p>
  
  <p>1) Client</p>
  
  <p>2) Requestor</p>
  
  <p>3) Address</p>
  
  <p>4) Email</p>
  
  <p>So far, I can autocomplete the Client with this code:</p>
  
  <pre><code> &lt;script type="text/javascript"&gt;
              $(document).ready(function(){
                  $("#Client").autocomplete({
                      source:'getClient.php',
                      minLength:1
                  });
              });
      &lt;/script&gt;
  </code></pre>
  
  <p>However, I need to get the next data (Requestors, Address...) using the Client's values instead of showing all the requestors and all the addresses from the database.</p>
  
  <p>I've been trying for 3 hours and I just don't seem to get any data.
  As an example, I've just set my Requestor input with an onclick.</p>
  
  <pre><code>&lt;input type="text" name="Req" size="60" id="Reqt" onclick="getreq()"&gt;&lt;br&gt;
  </code></pre>
  
  <p>This was the last code attempt I've done so far:</p>
  
  <pre><code> &lt;script type="text/javascript"&gt;
              $(document).ready(function()
              {
   function getreq(){
              //get the username
      var Client = $('#Client').val();
      //use ajax to run the check
             $.ajax({
              data:  Client,
              url:   'getReq.php',
              type:  'post',
  
              success:  function (response) {
                      $("#Reqt").autocomplete({
                      source:'getReq.php',
                      minLength:1
                  });
              }
      });
     }
  });
      &lt;/script&gt;
  </code></pre>
  
  <p>And my PHP looks like this</p>
  
  <pre><code>&lt;?php
   mysql_connect("localhost","user","pass");
   mysql_select_db("test");
  
   $client = mysql_real_escape_string($_POST['Client']);
  
   $query=mysql_query('SELECT * FROM client WHERE Clients ="'.$client.'"');
   $json=array();
  
      while($Reqt=mysql_fetch_array($query)){
           $json[]=array(
                      'value'=&gt; $Reqt["Requestor"],
                      'label'=&gt;$Reqt["Requestor"]
                          );
      }
  
   echo json_encode($json);
  
  ?&gt;
  </code></pre>
  
  <p>Like I said, I've been trying this for hours and I'm pretty new to Json, Ajax and Jquery, but I need to use those technologies, I would really appreciate any and all insight. Thanks in advance!</p>