- 爱易网页
-
C#教程
- 不知道什么原因点击select服务器端的步骤总要运行3次以上,求大神帮忙
日期:2014-05-16 浏览次数:20854 次
不知道什么原因点击select服务器端的方法总要运行3次以上,求大神帮忙
<meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1">
<link rel="stylesheet" href="jquery.mobile-1.0a4.1.min.css">
<script src="jquery-1.5.min.js"></script>
<script src="jquery.mobile-1.0a4.1.min.js"></script>
<script>
//定义一个函数用以显示当前时间
function ms() {
loms();
displayTime();
}
function displayTime() {
var elt_1 = document.getElementById("falsh_1");
var elt_2 = document.getElementById("falsh_2");
var now = new Date();
elt_1.innerHTML = now.toLocaleTimeString();
elt_2.innerHTML = now.toLocaleTimeString();
setTimeout(displayTime,1000);
callServer();
}
function ajaxRomex(){
if (window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP");
} else if (window.XMLHttpRequest) {
return new XMLHttpRequest();
}
}
var xhr;
var url;
function callServer() {
url = "Default.aspx?_" + new Date().getTime();
xhr = ajaxRomex();
xhr.onreadystatechange = updatePage;
xhr.open("GET", url, false);
xhr.send(null);
}
function addbu() {
var temp = document.getElementById("textarea9").value;
alert(temp);
url = "Default.aspx?add=" + temp;
xhr.open("POST", url, false);
xhr.send(null);
}
function updatePage() {
if (xhr.readyState == 4 && xhr.status == 200) {
var dom = xhr.responseXML;
document.getElementById("s1").value = dom.getElementsByTagName("Temperature")[0].firstChild.nodeValue;
document.getElementById("s2").value = dom.getElementsByTagName("Humidity")[0].firstChild.nodeValue+"%";
document.getElementById("s3").value = dom.getElementsByTagName("Airquality")[0].firstChild.nodeValue+"级";
document.getElementById("s4").value = dom.getElementsByTagName("Fan")[0].firstChild.nodeValue == 0 ? "开" : "关";
if (dom.getElementsByTagName("Temperature")[0].firstChild.nodeValue > dom.getElementsByTagName("jingjie")[0].firstChild.nodeValue) {
document.getElementById("s1").style.color = "Red";
} else {