O'Reilly logo

Instant typeahead.js by Toby Osbourn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Fetching data from the server (Should know)

So far we have covered fetching local data and fetching some pre-made JSON. These methods are really great if we know in advance what our dataset is going to be and it doesn't update too frequently. But what if you want people to be able to search on live data that could be updated a second before the search is made? This is where remote data comes in.

In this recipe, we will make a dummy server script to highlight how this functionality works. Normally, of course, there would be database calls and some non-trivial text processing, but this isn't a book about that!

Getting ready

We will be writing a small PHP script to demonstrate how easy it is to query a remote server. I am using PHP because it is well ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required