<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    This Is A FineDay

      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      93 隨筆 :: 0 文章 :: 69 評論 :: 0 Trackbacks

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    ? "<html xmlns="<head>
    <title>Dynamically Editing Page Content</title>

    <script type="text/javascript">
    var xmlHttp;

    function createXMLHttpRequest() {
    ??? if (window.ActiveXObject) {
    ??????? xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    ??? }
    ??? else if (window.XMLHttpRequest) {
    ??????? xmlHttp = new XMLHttpRequest();
    ??? }
    }
    ???
    function doSearch() {
    ??? createXMLHttpRequest();
    ??? xmlHttp.onreadystatechange = handleStateChange;
    ??? xmlHttp.open("GET", "dynamicContent.xml", true);
    ??? xmlHttp.send(null);
    }
    ???
    function handleStateChange() {
    ??? if(xmlHttp.readyState == 4) {
    ??????? if(xmlHttp.status == 200) {
    ??????????? clearPreviousResults();
    ??????????? parseResults();
    ??????? }
    ??? }
    }

    function clearPreviousResults() {
    ??? var header = document.getElementById("header");
    ??? if(header.hasChildNodes()) {
    ??????? header.removeChild(header.childNodes[0]);
    ??? }

    ??? var tableBody = document.getElementById("resultsBody");
    ??? while(tableBody.childNodes.length > 0) {
    ??????? tableBody.removeChild(tableBody.childNodes[0]);
    ??? }
    }

    function parseResults() {
    ??? var results = xmlHttp.responseXML;

    ??? var property = null;
    ??? var address = "";
    ??? var price = "";
    ??? var comments = "";

    ??? var properties = results.getElementsByTagName("property");
    ??? for(var i = 0; i < properties.length; i++) {
    ??????? property = properties[i];
    ??????? address = property.getElementsByTagName("address")[0].firstChild.nodeValue;
    ??????? price = property.getElementsByTagName("price")[0].firstChild.nodeValue;
    ??????? comments = property.getElementsByTagName("comments")[0].firstChild.nodeValue;
    ???????
    ??????? addTableRow(address, price, comments);
    ??? }
    ???
    ??? var header = document.createElement("h2");
    ??? var headerText = document.createTextNode("Results:");
    ??? header.appendChild(headerText);
    ??? document.getElementById("header").appendChild(header);
    ???
    ??? document.getElementById("resultsTable").setAttribute("border", "1");
    }


    function addTableRow(address, price, comments) {
    ??? var row = document.createElement("tr");
    ??? var cell = createCellWithText(address);
    ??? row.appendChild(cell);
    ???
    ??? cell = createCellWithText(price);
    ??? row.appendChild(cell);
    ???
    ??? cell = createCellWithText(comments);
    ??? row.appendChild(cell);
    ???
    ??? document.getElementById("resultsBody").appendChild(row);
    }

    function createCellWithText(text) {
    ??? var cell = document.createElement("td");
    ??? var textNode = document.createTextNode(text);
    ??? cell.appendChild(textNode);
    ???
    ??? return cell;
    }
    </script>
    </head>

    <body>
    ? <h1>Search Real Estate Listings</h1>
    ?
    ? <form action="#">
    ??? Show listings from
    ??????? <select>
    ??????????? <option value="50000">$50,000</option>
    ??????????? <option value="100000">$100,000</option>
    ??????????? <option value="150000">$150,000</option>
    ??????? </select>
    ??????? to
    ??????? <select>
    ??????????? <option value="100000">$100,000</option>
    ??????????? <option value="150000">$150,000</option>
    ??????????? <option value="200000">$200,000</option>
    ??????? </select>
    ??? <input type="button" value="Search" onclick="doSearch();"/>???
    ? </form>
    ?
    ?
    ?
    ? <span id="header">
    ?
    ? </span>

    ? <table id="resultsTable" width="75%" border="0">
    ??? <tbody id="resultsBody">
    ??? </tbody>
    ? </table>
    </body>
    </html>

    dynamicContent.xml文件
    <?xml version="1.0" encoding="UTF-8"?>
    <properties>
    ??? <property>
    ??????? <address>812 Gwyn Ave</address>
    ??????? <price>$100,000</price>
    ??????? <comments>Quiet, serene neighborhood</comments>
    ??? </property>???
    ??? <property>
    ??????? <address>3308 James Ave S</address>
    ??????? <price>$110,000</price>
    ??????? <comments>Close to schools, shopping, entertainment</comments>
    ??? </property>???
    ??? <property>
    ??????? <address>98320 County Rd 113</address>
    ??????? <price>$115,000</price>
    ??????? <comments>Small acreage outside of town</comments>
    ??? </property>???
    </properties>


    評論

    # re: Ajax增加Table內(nèi)容 2009-07-02 09:23 xior
    太謝謝,這份代碼很棒,太棒了!  回復(fù)  更多評論
      

    # re: Ajax增加Table內(nèi)容 2009-11-03 13:37 zhd
    afffaf  回復(fù)  更多評論
      

    # re: Ajax增加Table內(nèi)容 2010-08-23 15:07 cosplay
    good  回復(fù)  更多評論
      

    主站蜘蛛池模板: 亚洲成人中文字幕| 91在线精品亚洲一区二区| 亚洲国产精品狼友中文久久久| 亚洲中文字幕久久精品无码2021| 亚洲网红精品大秀在线观看 | h视频在线免费观看| 99麻豆久久久国产精品免费| 手机看片国产免费永久| 国产成人综合亚洲亚洲国产第一页| 亚洲乱亚洲乱淫久久| 无码AV动漫精品一区二区免费| 久久久久久毛片免费播放| 免费吃奶摸下激烈视频| 亚洲黄色高清视频| 无码中文在线二区免费| 亚洲精品成人片在线播放| 亚洲va中文字幕| 免费福利在线视频| 国产18禁黄网站免费观看| 亚洲无圣光一区二区| 国产午夜免费高清久久影院| 亚洲视屏在线观看| 韩国18福利视频免费观看| 在线观看亚洲一区二区| 最近最好的中文字幕2019免费| 亚洲网址在线观看| 四虎www成人影院免费观看| 亚洲大尺码专区影院| 又爽又高潮的BB视频免费看| 一个人看的www免费高清| 日韩免费一级毛片| 亚洲一卡2卡4卡5卡6卡残暴在线| 女人被弄到高潮的免费视频| selaoban在线视频免费精品| 婷婷亚洲久悠悠色悠在线播放 | 亚洲Av无码一区二区二三区| 国产精品自在自线免费观看| 亚洲综合激情五月丁香六月| 亚洲精品在线免费观看| 亚洲色图在线播放| 在线免费观看一级毛片|