title: What's a simple example of jQuery UI Autocomplete returning non-local results on AppEngine
body: <p>I am trying to implement a jQuery autocomplete search bar to be hosted on Google AppEngine (GAE). I have seen posts indicating that if I wish to use a remote source, I must filter the results myself. If I store the list in the script as an array, if filters correctly, so  I have also tried converting the large server-side JSON array returned from GAE to a local client array in order to avoid the need to manually filter. Neither try has worked. </p>
  
  <p>What is the easiest way (for a jQuery/.js beginner) to get filtered non-local results?</p>
  
  <p>This was my attempt to use the regex example provided in the jQueryui docs, and other examples posted on SO. If I type 'c' in the search bar, my dropdown list only shows and returns the letter c.</p>
  
  <p>GAE .py code:</p>
  
  <pre><code>class Search(webapp2.RequestHandler):
      def get(self):
          data = ["chickenpox", "chlamydia", "cholera" ]
          tags = json.dumps(data)
          self.response.out.write(tags)
  </code></pre>
  
  <p>template code:</p>
  
  <p>Note: <code>'/search'</code> directs to the GAE server handler that returns the json data.</p>
  
  <pre><code>&lt;script&gt;
  var availableTags = '/search';
  
  $(function() {                          
  $( "#autocomplete" ).autocomplete({
      source: function( request, response ) {
              var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( request.term ), "i" );
              response( $.grep( availableTags, function( item ){
                  return matcher.test( item );
              }) );
          },  
      minLength: 1,
       select: function( event, ui ) {
                  $("#user_input").html('Selected: '+ ui.item.value);
                  var entry = ui.item.value;
              }
          });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>Below was my attempt to convert <code>availableTags</code> to a local array so that autocomplete would filter the results itself.
  Is this kind of hack/workaround even possible? If not why not?</p>
  
  <pre><code>var availableTags = '/search';
  var new_local_array = $.parseJSON(availableTags);
  </code></pre>
  
  <p>Which method should I try and how? Thanks.</p>