I have a web application which has a search facility. On the home page I have a search box in which the user can enter the criteria for searching and click on the Search button. After the button is clicked, we send the AJAX request to the server (Struts Action), which hits the database using DAO layer and fetches the search result.
Now I want to send this search result back to the client side and render the result in a <div> tag using jQuery. One page can contain 10 results. If the user clicks on ‘next page’ we want to show another 10 records.
What would be the best way to do this?
I think that probably the best method is to use .load() jQuery method just to serve search results and manipulate via AJAX the content of the results div; then you can act on to the elements within the container div with .on method, in order to trigger the “go to the next page” event, for example. In this way you only need the container div and you’re free to build the results data elsewhere, using all the serverside languages that you need.