title: jQueryUI Autocomplete data from text/csv file with $.ajax
body: <p>I've been trying to amend the example from <a href="http://jqueryui.com/autocomplete/#maxheight" rel="nofollow">http://jqueryui.com/autocomplete/#maxheight</a> to work with input from a locally stored text/csv file looking like</p>
  
  <pre><code>ItemA
  ItemB
  ItemC
  ....
  </code></pre>
  
  <p>I am able to create an array from the data in the textfile and print it to console.log() but I'm not sure how to hand over this array to the autocomplete function. I've tried initializing the array a outside the function but when using it in autocomplete it will use the non-populated array a.</p>
  
  <pre><code>&lt;/style&gt;
  &lt;script type="text/javascript" language="javascript"&gt;
  
  
  $(document).ready(function() {
    $.ajax({
      type: "GET",
      url: "john.txt",
      dataType: "text",
      success: function(data) {processData(data);}
   });
  });
  
  var a = [];
  function processData(myTxt) {
      var myLines = myTxt.split(/\r\n|\n/);
      for (var i=1; i&lt;myLines.length; i++) {
            a.push(myLines[i]);
          }
          console.log(a);
  }
  
  
  $( "#tags" ).autocomplete({
      source: a
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>How do I pass the array correctly to autocomplete?</p>