【发布时间】:2015-12-08 20:41:40
【问题描述】:
我没有办法执行我的 html/php 网页。
这是场景:
从正文部分的 html 网页中,我加载了一个 php 脚本,该脚本从 mysql db 中检索数据并将其呈现在表中,然后将其返回到初始网页的部分中。 当我得到这张表时,Id(第一列)上有一个链接,假设通过点击它可以在同一页面的另一个部分提供信息,但它没有。 它在另一个网页上显示它的信息。
这是主要的html代码:
<html>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/w3css/w3.css">
<head>
<style>
#header {
background-color:black;
color:white;
text-align:center;
padding:5px;
}
#section {
width:100%;
float:left;
padding:5px;
}
#footer {
background-color:black;
color:white;
clear:both;
text-align:center;
padding:5px;
text-shadow: 1px 1px;
}
</style>
<script>
function getStudentStatus(Id) {
if (Id == "") {
document.getElementById("StuStat").innerHTML = "";
return;
} else {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("StuStat").innerHTML = xmlhttp.responseText;
}
}
console.log("looking for :"+Id);
xmlhttp.open("GET","getStudentStatus.php?StudentId="+Id,true);
xmlhttp.send();
}
}
function getStudentInfo(Id) {
if (Id == "") {
document.getElementById("StuInfo").innerHTML = "";
return;
} else {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("StuInfo").innerHTML = xmlhttp.responseText;
}
}
console.log("looking for :"+Id);
xmlhttp.open("GET","getStuInfo.php?StudentId="+Id,true);
xmlhttp.send();
}
}
var intShowResult = setInterval(function() {getStudentStatus("q") },60000);
</script>
</head>
<body onload="getStudentStatus('q')">
<div class="w3-container w3-orange">
<h1>Student Status</h1>
<h4>test bed</h4>
</div>
<br><br><br>
<div id="section">
<p>Result: <span id="StuStat"></span></p>
</div>
<div id="footer">
Copyright © xxxxxx.com
</div>
<div id="StuInfo">
<p>Cycle Info of:<span id="StuInfo"></span></p>
</div>
</body>
</html>
有什么想法吗? /库尔
【问题讨论】:
标签: javascript php html ajax