You might want to consider something like this, this is a very simple example of a remote data source. The get parameter in this example is 'q'
// Get your data source var dataSource = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'), queryTokenizer: Bloodhound.tokenizers.whitespace, remote: { url: 'path/to/your/url/json/datasource/?q=%QUERYSTRING', wildcard: '%QUERYSTRING' } }); // initialize your element var $typehead = $('#form input').typeahead(null, { source: dataSource }); // fire a select event, what you want once a user has selected an item $typehead.on('typeahead:select', function(obj, datum, name) { //your code here }); //////////////////////////////////// # in python (django) we get a query string using the request object passed through a view like this query = request.GET.get('q') or "" //the caveat [or ""] is just to prevent null exceptions ///////////////////////////////////
source share