Advertisement
nate_d

autocompletee

Jul 10th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(function() {
  2.             $("#autocomplete").autocomplete({
  3.                 source: function (request, response) {
  4.                     $.getJSON("localhost:5000/autocomplete", {
  5.                         q: request.term, // in flask, "q" will be the argument to look for using request.args
  6.                     }, function (data) {
  7.                         response(data.matching_results); // matching_results from jsonify
  8.                     });
  9.                 },
  10.                 minLength: 2,
  11.                 select: function (event, ui) {
  12.                     console.log(ui.item.value); // not in your question, but might help later
  13.                 }
  14.             });
  15.         })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement