I can't get the prefetch function in typeahead.js to work, but it works fine with local data. At first I tried a link to a servlet returning json objects or lists, but after a while I refused it and started checking the examples given. Therefore their examples link to pages that look like this: http://twitter.imtqy.com/typeahead.js/data/countries.json However, my script doesn't even work when I bind it to this page, even if I do the same as they are. I tried to copy this file to my local workspace and link it there to no avail. To check if he really made any calls, I made my crash servlet every time he received a request to receive, and of course it crashed when I ran the autocomplete example page, so this is not a cache problem. I tried downgrading jquery to 1.9.1, but that didn't work either (currently 1.10 is used). I tried using different versions of typeahead.js. I tried using Internet Explorer as well as google chrome to see if there was an error.
There must be something vital that I am missing, as I have exhausted every source of error that I could think of. Others seem to have no problem getting this to work.
Here is the code I'm using:
<!doctype html> <html> <head> <meta charset="utf-8" /> <title>Demo</title> <link rel="stylesheet" type="text/css" href="typeahead.js-bootstrap.css"> </head> <body> <script src="jquery.js"></script> <script src="typeahead.js"></script> <input type="text" class="typeahead" placeholder="test" /> <script> $(document).ready(function() {$('.typeahead').typeahead({ name: "Auto" , ttl_ms: 10000, prefetch: 'http://twitter.imtqy.com/typeahead.js/data/countries.json', </script> </body> </html>
Johan source share