您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
<!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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。