【发布时间】:2015-02-27 07:10:36
【问题描述】:
我必须在一个表上实现 Ajax,这样我就可以在每次 !小时。我的 JSP 代码是
< head >
< meta http - equiv = "Content-Type"
content = "text/html; charset=ISO-8859-1" >
< title > Insert title here < /title>
</head >
< body >
< jsp: useBean id = "bs" class = "beam_Status.BeamStatus_Bean" > < /jsp:useBean>
< br >
< h1 > Total Beamlines open are $ { bs.total_Beamopen()} < /h1>
<CENTER><H1>BEAMLINE STATUS</H1 > < /CENTER>
<center>
<table border = "1" cellpadding="1" width="750px" id="ajax">
<tr>
<th><h1><b>BEAMLINES</b > < /h1></th >
< th > < h1 > < b > STATUS < /b></h1 > < /th>
<th><h1>SYMBOLIC REPRESENTATION</h1 > < /th>
</tr >
< c: forEach
var = "country"
items = "${bs.beam_CurrentStatus()}" >
< h3 > < b >
< c: choose >
< c: when test = "${country.value == 'IN OPERATION'}" >
< tr >
< td class = "green"
style = "text-transform: uppercase; "
width = "400px" > < center > < h1 > $ {
country.key
} < /h1></center > < /td>
<td class="green" style="text-transform: uppercase; "width="300px"><center><h1> ${country.value}</h1 > < /center> </td >
< td width = "200px" > < center > < img src = "red.png"
align = "middle"
width = "100"
height = "110" / > < /center></td >
< /tr>
</c: when >
< c: otherwise >
< tr >
< td class = "red"
style = "text-transform: uppercase; "
width = "400px" > < center > < h1 > $ {
country.key
} < /h1></center > < /td>
<td class="red" style="text-transform: uppercase; "width="300px"><center> <h1>${country.value}</h1 > < /center> </td >
< td width = "200px" > < center > < img src = "green.png"
align = "middle"
width = "100"
height = "110" / > < /center></td >
< /tr>
</c: otherwise >
< /c:choose>
</b > < /h3>
</c: forEach >
< /table>
</center >
现在,整个页面都在刷新,我已经使用过了。
我对 Ajax 很陌生。请帮我在上面实现 Ajax。
【问题讨论】:
-
大写锁定在尖叫。请修正您的文字,以免全部大写。
-
从学习 Ajax 开始developer.mozilla.org/en-US/docs/AJAX/Getting_Started 然后你可以调用服务器,获取表格行并替换表格的内容。使用 setTimeout 触发下一次抓取。
-
@epascarello 感谢您的链接。但我无法理解要放入 httpRequest.onreadystatechange = function(){} 中的内容,就像在我的应用程序中一样,有一个按钮,当我点击表格时会更新。但我希望它自动更新。如何解决这个问题?如何使用 setTimeout ??
标签: javascript ajax jsp