Use AJAX to refresh the jsp content in a DIV
Copy codeThe Code is as follows:
<Script type = "text/javascript">
Var xmlhttp;
Function startrefresh (){
Xmlhttp = new XMLHttpRequest ();
Xmlhttp. open ("POST," ss. jsp ", true );
Xmlhttp. setRequestHeader ("Content-type", "application/x-www-form-urlencoded ");
// Xmlhttp. send ("name = wk"); -- added when parameters need to be transmitted
Xmlhttp. onreadystatechange = function (){
If (xmlhttp. readyState = 4)
If (xmlhttp. status = 200)
Document. getElementById ("mydvi"). innerHTML = xmlhttp. responseText;
}
}
</Script>
If you want this div to be automatically refreshed, you can use setInterval ('startrefresh () ', 5000) to automatically execute the startrefresh method every five seconds, another method is setTimeout ('startrefresh () ', 5000), but this method will only be executed once.