I want to implement a search input box that when you insert some chars it instantly show below the search results.
Like when you search an user in Facebook Search field at the top of the page, it displays in real time the resul开发者_C百科ts.
How can I do that? Can you give me some hints?
well i used jqueryui autocomplete to make the ajax call and piston to read the models.
Write a view which returns you the results according to query string (GET request) or POST parameter (POST request), depending on what you want. This view should return the results of this query, either rendered as a template for example or in another format (JSON, XML) which you can parse.
On frontend side (Javascript), define a handler which each time you type makes a request to the view above with the stuff which you typed as the query parameters. The callback should then render the results to this view into your page.
Check out django-ajax-search. Works very well and can be fairly customized.
精彩评论