Current location - Recipe Complete Network - Complete cookbook - Java servlet ajax can refresh the data of another table by clicking on a row of data in the table (without refreshing the whole page). How? Under the guidance of the great god.
Java servlet ajax can refresh the data of another table by clicking on a row of data in the table (without refreshing the whole page). How? Under the guidance of the great god.
Request data with ajax, wrap the table to be refreshed in one layer, and request to come back to replace the data in this layer. It can be easily implemented with jquery.

& ltdiv id="t 1 " >

& lt table & gt

& lttr & gt& ltTD onclick = " refer table 2(this)" tid = " 45 " & gt。 Click me to refresh table 2.

& lt/table & gt;

& lt/div & gt;

& ltdiv id="t2 " >

& lt table & gt

& lttr & gt& lttd & gt This is the data returned by the data page. & lt/tr & gt;

& lt/table & gt;

& lt/div & gt;

Function refertable2(em){

var url="/t2.jsp? id="+$(em)。 attr(" tid ");

$. Publish (url, function (HTML) (

$(“T2”)。 html(html);

});

}

= = = = = Here is the /t2.jsp page = = = = =

& lt table & gt

& lttr & gt& lttd & gt data in the first row

& lttr & gt& lttd & gt data in the second line

& lt/table & gt;