Use Ajax and IFRAME nesting to partially refresh the page. The javascript code is for reference only and needs to be modified as needed.
? 1. [Code] JavaScript code
Function cj_start (depname, groupid ){
VaR URLs = "<% = PATH %>/usergather. Action ";
VaR status = "";
VaR html_1 = "<IFRAME frameborder = \" 0 \ "scrolling = \" NO \ "width = \" 600 \ "Height = \" 60 \ "src = \" <% = basepath %> cj_status.jsp \ "style = \" margin-top: 3px; Vertical-align: middle; \ "> </iframe> ";
$ ("# Cj_status_html" ).html (html_1 );
VaR html_2 = "";
VaR cj_butoon = "";
$. Ajax ({
URL: URLs,
Type: "Post ",
Datatype: "JSON ",
Data: {depname: depname, groupid: groupid },
Success: function (data ){
If (data. cjstatus. length! = 0 ){
If (data. cjstatus [0] = "0 "){
Cj_button = "<input type = \" button \ "value = \" collection channel \ "Disabled = \" disabled \ "/> ";
$ ("# Cj_button_html" ).html (cj_button );
}
For (VAR I = 1; I <data. cjstatus. length; I ++ ){
Html_2 + = data. cjstatus [I] + "";
}
$ ("# Cj_status_html" ).html (html_2 );
} Else {
Html_2 = "Collection System error. Please contact the developer! ";
$ ("# Cj_status_html" ).html (html_2 );
}
}
});
}
2. [Code] part of JSP code
<Tr>
<TD id = "cj_button_html">
<Input type = "button" name = "caiji" value = "collection channel" onclick = "cj_start ('<% = depname %> ', '<% = groupid %>'); "/>
</TD>
</Tr>
<Tr>
<TD id = "cj_status_html">
</TD>
</Tr>
3. [Code] cj_status.jsp code
<% @ Page Language = "Java" Import = "Java. util. *" pageencoding = "UTF-8" %>
<% Http://www.bizhizu.cn/manhua?
String Path = request. getcontextpath (); cartoon image
String basepath = request. getscheme () + ": //" + request. getservername () + ":" + request. getserverport () + path + "/";
%>
<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en">
<HTML>
<Head>
<Base href = "<% = basepath %>">
</Head>
<Body>
<Div>
images/loading_16x16.gif"/> <span> collecting data. Please wait... </span>
</Div>
<Script language = "JavaScript">
Function myrefresh ()
{
Window. Location. Reload ();
}
SetTimeout ('myrefresh () ', 1000); // refresh once per second
</SCRIPT>
</Body>
</Html>
?
Partial page refreshing using Ajax and IFRAME nesting