廢話不多說了,直接給大家貼代碼了,具體代碼如下所示:
<td> <input type="button" value="訂單詳情" id="but<s:property value="#o.oid"/>" onclick="showDetail(<s:property value="#o.oid"/>)"/> <div id="div<s:property value="#o.oid"/>"></div> </td> <script type="text/javascript"> function showDetail(oid){ var but = document.getElementById("but"+oid); var div1 = document.getElementById("div"+oid); if(but.value == "訂單詳情"){ // 1.創(chuàng)建異步對象 var xhr = createXmlHttp(); // 2.設(shè)置監(jiān)聽 xhr.onreadystatechange = function(){ if(xhr.readyState == 4){ if(xhr.status == 200){ div1.innerHTML = xhr.responseText; }} } // 3.打開連接 xhr.open("GET", "${pageContext.request.contextPath}/ adminOrder_findOrderItem.action?oid="+oid+"&time= "+new Date().getTime(),true); // 4.發(fā)送 xhr.send(null); but.value = "關(guān)閉"; }else{ div1.innerHTML = ""; but.value="訂單詳情"; } } function createXmlHttp(){ var xmlHttp; try{ // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e){ try{// Internet Explorer xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e){ try{ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){} } } return xmlHttp; } </script> // 根據(jù)訂單的id查詢訂單項(xiàng): public String findOrderItem(){ // 根據(jù)訂單id查詢訂單項(xiàng): List<OrderItem> list = orderService.findOrderItem(order.getOid()); // 顯示到頁面: ActionContext.getContext().getValueStack().set("list", list); // 頁面跳轉(zhuǎn) return "findOrderItem"; } <table width="100%"> <s:iterator var="orderItem" value="list"> <tr> <td><img width="40" height="45" src="${ pageContext.request.contextPath }/<s:property value="#orderItem.product.image"/>"></td> <td><s:property value="#orderItem.product.pname"/></td> <td><s:property value="#orderItem.count"/></td> <td><s:property value="#orderItem.subtotal"/></td> </tr> </s:iterator> </table>
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)建站chinadenli.net,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
當(dāng)前文章:JS實(shí)現(xiàn)ajax異步瀏覽器兼容問題-創(chuàng)新互聯(lián)
文章來源:http://chinadenli.net/article42/dggjec.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供Google、建站公司、網(wǎng)站策劃、品牌網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)、企業(yè)建站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容