Programming - - By Harry Fuecks

Server Side Autocompletion with PHP and XMLHttpRequest

Christian has an interesting new feature called “Livesearch” on his blog, described here. Try typing “PHP” in the search box on the right and see what happens.

On the client side it’s made possible with http://blog.bitflux.ch/livesearch.js – you’ll see it using XMLHttpRequest to poll another PHP script that looks like http://blog.bitflux.ch//livesearch.php?s=PHP – the script renders search results as HTML which is easily “embedded” in the output with some DOM manipulation.

This is the kind of thing I was trying to describe in Separating Browser from Resource.

Think Christians example proves that this approach can be fast and effective – if you didn’t look you’d assume the search results were sent with the page on the initial request, rather then being rendered dynamically.

Sponsors