<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 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      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內容 2009-07-02 09:23 xior
    太謝謝,這份代碼很棒,太棒了!  回復  更多評論
      

    # re: Ajax增加Table內容 2009-11-03 13:37 zhd
    afffaf  回復  更多評論
      

    # re: Ajax增加Table內容 2010-08-23 15:07 cosplay
    good  回復  更多評論
      

    主站蜘蛛池模板: 老司机午夜性生免费福利| 亚洲女人影院想要爱| 一区二区3区免费视频| 国产极品粉嫩泬免费观看| 亚洲AV日韩AV无码污污网站| 国内免费高清在线观看| 亚洲日韩精品无码AV海量| 曰皮全部过程视频免费国产30分钟| a级成人毛片免费图片| 免费在线黄色网址| 一级免费黄色毛片| 亚洲成A人片在线观看WWW| 久久国产乱子免费精品| 亚洲国产一区二区三区青草影视| 精品免费视在线观看| 亚洲无成人网77777| 四虎永久在线精品免费网址| 人人狠狠综合久久亚洲| 亚洲国产成人久久精品99| 久久www免费人成看国产片| 亚洲a在线视频视频| 99无码人妻一区二区三区免费| youjizz亚洲| 一本久到久久亚洲综合| 你是我的城池营垒免费看| 亚洲色大成网站www永久| 国产一级理论免费版| 国产在线国偷精品免费看| 亚洲国产日韩一区高清在线| 亚洲免费综合色在线视频| 香港经典a毛片免费观看看| 国产亚洲av人片在线观看| 麻豆视频免费播放| 久久精品国产亚洲AV电影网| 国产亚洲精品无码拍拍拍色欲| 最近免费中文字幕大全免费| 国产成人人综合亚洲欧美丁香花 | 一个人免费观看视频www| 免费夜色污私人影院网站电影| 亚洲AV无码久久| 性做久久久久免费观看|