title: jQueryUI autocomplete mapping response data
body: <p>another question about jQuery autocomplete with wich i'm having problems despite the numerous resources on this forum or on jQuery docs.</p>
  
  <p>I'm having a hard time mapping response data from a PHP script with jQuery UI. Here is the code:</p>
  
  <pre><code>$("#shared-with").autocomplete({
    source: function(request, response) {
  
      $.ajax({
        type: 'get',
        url: 'ajax/search.php',
        data: { term: request.term },
        success: function(data){
  
             // alert(data);
             response($.map(data, function(c) {
               return {
                   label: c.name,
                   value: c.nametag
               }
             }));
  
       }
     });
   }
  });
  </code></pre>
  
  <p>My problem is that the response/map function is not properly understood by jQuery autocomplete although the data that is sent back from search.php looks like:</p>
  
  <pre><code>echo json_encode(
       array('name' =&gt; 'Bill', 'nametag' =&gt; 'Big Bill'),
       array('name' =&gt; 'Fred', 'nametag' =&gt; 'Small Fred'),
  );
  </code></pre>
  
  <p>PS: when i alert "data" in javascript popup show me a valid javascript array/object...
  PS: "#shared-with" is just the textarea</p>
  
  <p>Any idea ? Thanks in advance.</p>