title: Twitter Typeahead Ajax results undefined
body: <p>I'm building a autocomplete with Twitter typeahead using an ajax JSON call to my PHP file to get some data but it keeps displaying the following in the dropdown result list:</p>
  <p>undefined</p>
  <p>undefined</p>
  <p>undefined</p>
  <p>but when i do:</p>
  <pre><code>alert(data); 
  </code></pre>
  <p>I get the right data displayed but somehow the autocomplete list keeps displaying undefined, I've read and tried multiple things by some articles here on StackOverflow, but I can't seem to get it to work.</p>
  <p>I have to following jquery code:</p>
  <pre><code>      $('.item-name .typeahead').typeahead(null,{
        source: function (query, process) {
          $.ajax({
            url: 'ajaxItems.php',
            type: 'POST',
            dataType: 'JSON',
            data: 'query=' + query,
            success: function(data) {
              // alert(data);
              process(data);
            }
          });
        }
      });
  </code></pre>
  <p>And my ajaxItems.php has the following code for testing purpose:</p>
  <pre><code>&lt;?PHP
  $results = array();
  
  $results[] = 'jeans';
  $results[] = 'sweater';
  
  $json =  json_encode($results);
  print_r($json);
  ?&gt;
  </code></pre>
  <p>The JSON output is as follows:</p>
  <pre><code>[&quot;jeans&quot;,&quot;sweater&quot;]
  </code></pre>
  <p>I hope someone can shine some light on what I'm doing wrong or point me in the right direction.</p>
  <p><em>edit</em>
  I am using the following typeahead file:
  <a href="http://twitter.github.io/typeahead.js/releases/latest/typeahead.bundle.js" rel="nofollow noreferrer">http://twitter.github.io/typeahead.js/releases/latest/typeahead.bundle.js</a></p>