您好,登錄后才能下訂單哦!
<!DOCTYPE html> <html> <head> <title></title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <!-- <script src="../JS/AjaxRequest.js"></script> --> <script language="javascript" src="../JS/remind.js"></script> <script language="javascript"> var xmlHttp; var id = 20456; function showUser(str) { xmlHttp = GetXmlHttpObject() if (xmlHttp == null) { alert("Browser does not support HTTP Request"); return; } str = 20215; var url = "bbsAction.php?action=getBbs"; url = url + "&q=" + str; url = url + "&sid=" + Math.random(); //alert(url); xmlHttp.onreadystatechange = stateChanged; xmlHttp.open("GET", url, true); xmlHttp.send(null); } function stateChanged() { if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") { xmlDoc = xmlHttp.responseXML; var id = xmlDoc.getElementsByTagName("id")[0].childNodes[0].nodeValue;//獲取XML文檔中的id節點的第一個子節點的值 //alert(id.length); bbsid = id; var content = xmlDoc.getElementsByTagName("title")[0].firstChild.nodeValue;//獲取XML文檔中的title節點的第一個子節點的值 var sendTime = xmlDoc.getElementsByTagName("sendTime")[0].firstChild.nodeValue; //獲取XML文件中的time節點的第一個子節點的值 var remindMessage = new PopBubble(300, 200, " ", content, sendTime); //alert(remindMessage); remindMessage.box(null, null, null, screen.height - 30); //設置彈出窗口的左邊、右邊、頂邊和底邊框的位置 remindMessage.speed = 10; //設置窗口的彈出速度 remindMessage.step = 2; //設置窗口的彈出步幅 //alert("12"); remindMessage.show(); //彈出窗口 PopBubble.prototype.oncommand = function() { window.open("BbsServlet?action=getDetail&id=" + id, "", "width=513,height=567,scrollbars=1"); this.close = true; this.hide(); //收縮窗口 } /* document.getElementById("id").innerHTML = xmlDoc.getElementsByTagName("id")[0].childNodes[0].nodeValue; document.getElementById("title").innerHTML = xmlDoc.getElementsByTagName("title")[0].childNodes[0].nodeValue; document.getElementById("content").innerHTML = xmlDoc.getElementsByTagName("content")[0].childNodes[0].nodeValue; document.getElementById("sendTime").innerHTML = xmlDoc.getElementsByTagName("sendTime")[0].childNodes[0].nodeValue; */ } } function GetXmlHttpObject() { var objXMLHttp = null; if (window.XMLHttpRequest) { objXMLHttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP"); } return objXMLHttp; } window.onload = function() { showUser(id); window.setInterval(showUser, 10000); } </script> </head> <body> <!-- <div></div> <div > <span id="id"></span> <span id="title"></span> <span id="content"></span> <span id="sendTime"></span> </div> --> </body> </html>
bbsAction.php
<?php header('Content-Type: text/xml'); header("Cache-Control: no-cache, must-revalidate"); //A date in the past header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); $q = $_GET["q"]; $con = mysql_connect('localhost', 'root', '123456'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("surprise", $con); //$q = "201"; //$sql = "SELECT * FROM tb_bbs WHERE id = " . $q . ""; $sql = "SELECT * FROM tb_bbs limit 10"; $result = mysql_query($sql); echo '<?xml version="1.0" encoding="utf-8"?><bbs>'; while ($row = mysql_fetch_array($result)) { echo '<news>'; echo "<id>" . $row['id'] . "</id>"; echo "<title>" . $row['title'] . "</title>"; echo "<content>" . $row['content'] . "</content>"; echo "<sendTime>" . $row['sendTime'] . "</sendTime>"; echo '</news>'; // echo "<job>" . $row['id'] . "</job>"; } echo "</bbs>"; mysql_close($con); ?>
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。