jspajax自动刷新:jsp+ajax自动刷新例子(转)来源: 发布时间:星期一, 2009年11月30日 浏览:882次 评论:0
![]() ![]() <%@ page contentType="text/html; char ![]() <% //设置输出信息 ![]() ![]() response. ![]() ![]() response. ![]() out.pr ![]() for( ![]() ![]() out.pr ![]() ![]() ![]() "型笔记本</name>"); out.pr ![]() ![]() ![]() } out.pr ![]() out.close ![]() %> 2、发送ajax请求 ![]() <head> <META http-equiv=Content-Type content="text/html; char ![]() </head> <script language="javascript"> var XMLHttpReq; //创建XMLHttpRequest对象 function createXMLHttpRequest ![]() ![]() XMLHttpReq = ![]() ![]() } ![]() ![]() try { XMLHttpReq = ![]() } catch (e) { try { XMLHttpReq = ![]() } catch (e) {} } } } //发送请求 ![]() function sendRequest ![]() createXMLHttpRequest ![]() var url = "auto.jsp"; XMLHttpReq.open("GET", url, true); XMLHttpReq.onreadystatechange = processResponse;//指定响应 ![]() XMLHttpReq.send(null); // 发送请求 } // 处理返回信息 ![]() function processResponse ![]() ![]() ![]() ![]() ![]() ![]() DisplayHot ![]() ![]() ![]() } ![]() window.alert("您所请求 ![]() ![]() } } } function DisplayHot ![]() var name = XMLHttpReq.responseXML.getElementsByTagName("name")[0].firstChild.nodeValue; var count = XMLHttpReq.responseXML.getElementsByTagName("count")[0].firstChild.nodeValue; document.getElementById("product").innerHTML = name; document.getElementById("count").innerHTML = count; } </script> <body _disibledevent=> <table style="BORDER-COLLAPSE: collapse" borderColor=#111111 cellSpacing=0 cellPadding=0 width=200 bgColor=#f5efe7 border=0> <TR> <TD align=middle bgColor=#dbc2b0 height=19 colspan="2"><B>正在热卖 ![]() </TR> <tr> <td height="20"> 型号:</td> <td height="20" id="product"> </td> </tr> <tr> <td height="20"> 销售数量:</td> <td height="20" id="count"> </td> </tr> </body> </table> 0
相关文章读者评论
发表评论 |