Ajax load formatted table
I have a jsp page(page1.jsp) that I use to query a database and display the result in a table with a tree structure. I use a jquery plugin called treetable to do this.
On a different page (page2.jsp) i use ajax to get the first page(page1.jsp). BUT the problem is that I loose the treetable structure when the page1.jsp is loaded in this new page2.jsp.This is the javascript function in page2.jsp used to load page1.jsp
function loadpage1()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","page1.jsp",true);
xmlhttp.send();
}
The treeTable is applied to a table with class like开发者_运维百科 this
$(".tree").treeTable();
and I call the the ajax function like this
<table >
<tr onclick="loadpage1()" >
<td id="myDiv">Load</td>
</tr>
</table>
Is there a way to retain the tree structure in Page2.jsp? Thanks in advance.
精彩评论