I am trying to create a search result page with asp.net and jQuery. It
has to work in an AJAX manner. What I want is that I send the page
number to server via an AJAX call and the server can return an html
block so that I can attach this html block to an area in the page in
the callback after the AJAX call.
But I don’t know how to assemble the html block on the server side. Is
there a good way or some kind of engine to achieve this ? Or should I
just hard-code it like:
<table><tr><td>My result</td></tr> </table>
and return this text to client?
There are multiple ways of doing this – you have touched on one:
Return JSON, parse it using standard JavaScript methods into JS objects and:
2.1 Generate markup in JavaScript and add it.
2.2 Find the values in the objects and put them in the HTML.
2.2 Use a client side template library and bind the objects.