Boot Error

please help me resolve this error using Bootstrap typeahead.

Here is my php code that I use to call the source.

function getUser() { $sth = mysql_query("SELECT id,contact FROM cinfo ORDER BY id ASC"); $rows = array(); while ($r = mysql_fetch_assoc($sth)) { $rows[] = $r; } print json_encode($rows); } 

Here is my javascript file

UPDATE 2 JS

  $('.user').typeahead({ source : function(typeahead, query) { return $.post('/ticket/getUser', { query : query, }, function(data) { return typeahead.process(data); }) }, property : 'contact' }); 

Now I get the following error: https://gist.github.com/1866577#gistcomment-263183

I am using the following bootstrap typeahead script https://gist.github.com/1866577

Thanks.

0
source share
2 answers

You want to display contact not cinfo because cinfo is the name of the table

 $('.user').typeahead({ source: '/ticket/getUser', display:'contact', id: 'id' }); 

UPDATE:

It looks like you want to use the 'property' option:

 $('.user').typeahead({ source: '/ticket/getUser', property:'contact' }); 

UPDATE2:

I think you need to process the returned data first. Try the following:

 $('.user').typeahead({ source: function (typeahead, query) { return $.post('/ticket/getUser', { query: query }, function (data) { return typeahead.process(data); }); }, property:'contact' }); 
+1
source

If you encounter difficulties in working with my horn, if you have problems with the fact that this Gist works, you can try your full typeahead extension, which has the function you are looking for and is supported by documentation and demos.

https://github.com/tcrosen/twitter-bootstrap-typeahead

+1
source

All Articles