title: jQuery autocomplete in Flask
body: <p>Can't make jQuery autocomplete widget work with Flask framework. (<a href="http://jqueryui.com/autocomplete/#remote" rel="noreferrer">http://jqueryui.com/autocomplete/#remote</a> here is an example)
  <br>
  In <strong>manage.py</strong> I got the following :</p>
  
  <pre><code>@app.route('/autocomplete', methods=['GET'])
  def autocomplete():
      results = []
      search = request.args.get('autocomplete')
      for mv in db_session.query(Movie.title).filter(Movie.title.like('%' + str(search) + '%')).all():
          results.append(mv[0])
      return jsonify(json_list=results) 
  </code></pre>
  
  <p>My <strong>index.html</strong> file:</p>
  
  <pre><code>    &lt;head&gt;
      ...
      &lt;link href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" rel="Stylesheet"&gt;&lt;/link&gt;
      &lt;script src="../static/js/jquery.js"&gt;&lt;/script&gt;
      &lt;script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js" &gt;&lt;/script&gt;
  
  
      &lt;script type="text/javascript"&gt;
      $(function() {
          $.ajax({
              url: '{{ url_for("autocomplete") }}'
              }).done(function (data) {
                  $('#autocomplete').autocomplete({
                      source: data.json_list,
                      minLength: 2
                  });
              });
          });
      &lt;/script&gt;
      ...
      &lt;/head&gt;
      &lt;body&gt;
      ...
         &lt;div&gt;
            &lt;input name="autocomplete" type="text" id="autocomplete" class="form-control input-lg"/&gt;
         &lt;/div&gt;
      ...
      &lt;/body&gt;
  </code></pre>
  
  <p>Looks like dev tools in firefox don't return any errors.
  The terminal returns the following:</p>
  
  <blockquote>
    <p>"GET /autocomplete HTTP/1.1" 200 - <br>"GET / HTTP/1.1" 200 - <br>"GET
    /static/css/bootstrap.css HTTP/1.1" 304 - <br>"GET /static/js/jquery.js
    HTTP/1.1" 304 -</p>
  </blockquote>
  
  <p>The widget just doesn't work. Since I don't know much about jQuery I can't figure out what causes the problem. Can anybody help me please ?</p>