<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 :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      93 隨筆 :: 0 文章 :: 69 評(píng)論 :: 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>


    評(píng)論

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

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

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

    主站蜘蛛池模板: 免费一级毛片不卡在线播放| 亚洲国产精品福利片在线观看| 美女被免费视频网站a| 国产综合亚洲专区在线| 24小时日本韩国高清免费| 亚洲Av永久无码精品一区二区| 久久亚洲高清综合| 精品福利一区二区三区免费视频| 综合偷自拍亚洲乱中文字幕| 国产成A人亚洲精V品无码性色| 在线看片免费不卡人成视频| 一二三区免费视频| 亚洲噜噜噜噜噜影院在线播放| 亚洲成A人片在线观看中文| 一级毛片在线免费看| 18禁亚洲深夜福利人口| 香蕉蕉亚亚洲aav综合| 国产精品美女自在线观看免费| 久久久免费的精品| 特级一级毛片免费看| 亚洲宅男天堂a在线| 亚洲香蕉网久久综合影视| 成人免费a级毛片无码网站入口| 国产一级一毛免费黄片| 亚洲日本天堂在线| 久久亚洲精品成人AV| 可以免费观看一级毛片黄a | 四虎影视在线影院在线观看免费视频| 亚洲精品无码成人| 久久精品亚洲一区二区三区浴池| 免费又黄又爽又猛的毛片| 毛片a级毛片免费观看品善网| 日韩精品免费在线视频| 很黄很色很刺激的视频免费| av成人免费电影| 美女扒开尿口给男人爽免费视频| 国产成人亚洲合集青青草原精品 | 性做久久久久免费观看| 久久久久久免费视频| 免费精品无码AV片在线观看| XXX2高清在线观看免费视频|