title: ajax with jquery ui autocomplete
body: <p>I have created an autosuggestion list using jquery and WordPress function. My autosuggestion working fine. I am giving my code here</p>
  
  <blockquote>
    <p>Jquery Code</p>
  </blockquote>
  
  <pre><code>(function ($) {
    $(document).ready(function () {
        $('#my_ajax').autocomplete({
          // minChars: 1,
          source: function(request, response) {
            $.ajax({
              type: 'POST',
              dataType: 'json',
              url: devel_ajax.ajaxurl,
              data: 'action=my_ajax'+'&amp;name='+request.term,
              success: function(data) {
  
                response( $.map( data, function( item ) {
                    return {
                        label: item.title,
                        value: item.title
                    }
                }));
  
              }
            });
          },
          minLength: 3,
  
  
    });
  
   })(jQuery);
  </code></pre>
  
  <blockquote>
    <p>PHP Code</p>
  </blockquote>
  
  <pre><code>function user_autocomplete($value){
        global $wpdb;
        $name = $wpdb-&gt;esc_like(stripslashes($value));
        $users = $wpdb-&gt;get_results("SELECT DISTINCT
          $wpdb-&gt;users.ID
          FROM $wpdb-&gt;users
           WHERE LOWER($wpdb-&gt;users.user_login) LIKE LOWER('".$name."%')");
          $autocomplete = array();
          foreach($users as $key =&gt; $user){
            $user_info = get_userdata($user-&gt;ID);
            $firstname = $user_info-&gt;first_name;
            $lastname = $user_info-&gt;last_name;
          if(!empty($firstname) || !empty($lastname)){
            $username = ucfirst($firstname) . ' '. ucfirst($lastname);
          }else{
            $username = $user_info-&gt;user_login;
          }
          $email = $user_info-&gt;user_login; 
          $website = $user_info-&gt;website; 
          $autocomplete[$user-&gt;ID] = array(
          'ID' =&gt; $user-&gt;ID,
          'Name'    =&gt; $username
          'email'    =&gt; $email
          'website'    =&gt; $website
          );
      }
      return $autocomplete;
    }
  </code></pre>
  
  <blockquote>
    <p>HTML Code</p>
  </blockquote>
  
  <pre><code>&lt;form action='' method='POST' role="form" class="bottom-space"&gt;
  &lt;div class="form-group"&gt;
    &lt;input id="my_ajax" autofocus="" value="" type="text" name="q" placeholder="my_ajax" style="width:100%;max-width:600px;outline:0" autocomplete="off"&gt;
    &lt;input id="firstname" name="firstname" type="hidden" value=''&gt;
    &lt;input id="lastname" name="lastname" type="hidden" value=''&gt;
    &lt;input id="id" name="user_id" type="hidden" value=''&gt;
    &lt;input id="email" name="email" type="hidden" value=''&gt;
    &lt;input id="website" name="email" type="hidden" value=''&gt;
  &lt;/div&gt;
  &lt;submit type="submit" class="btn btn-default"&gt;Submit
    Button&lt;/submit&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>But the problem is I can not set others hidden input Field. Any kind of help or suggestions highly appreciable. </p>