title: Use Google Suggest with JavaScript
body: <p>I want to add the autocomplete / suggest feature of the Google Search to an input in a HTML page.</p>
  
  <p>If I open a <a href="http://blog.shreyaschand.com/2013/01/03/google-autocomplete-api/" rel="nofollow">URL</a> like this with Firefox:</p>
  
  <pre><code>suggestqueries.google.com/complete/search?client=firefox&amp;q=stacko&amp;callback=abc
  </code></pre>
  
  <p>It downloads a file like this:</p>
  
  <pre><code>["stacko",["stackoverflow","stackoverflowerror","stackoverflowexception","stackops","stackoverflow api","stackoverflow careers","stackoverflow java","stackoverflow deutsch","stackoverflow wiki","stackoverflow reputation"]]
  </code></pre>
  
  <p>How can I do this in JavaScript? I want to get an array with the results.</p>
  
  <p>// Edit: Here is my tried code:</p>
  
  <pre><code>var txtFile = new XMLHttpRequest();
  txtFile.open("GET", "http://suggestqueries.google.com/complete/search?client=firefox&amp;q=stacko&amp;callback=abc", true);
  txtFile.onreadystatechange = function() {
      text = txtFile.responseText;
      alert(text);
  }
  txtFile.send(null);
  </code></pre>
  
  <p>This creates an empty alert.</p>