你好吗,我已经为此工作了 2 个小时,当我更改它时,我似乎无法让我的页面动态显示信息。如果有人能告诉我出了什么问题,将不胜感激。
这是我的 HTML
<h2>Feedbacks</h2>
<form>
<select onchange="viewFeedback(this.value);">
<option value="unread">View Unread</option>
<option value="all" >View All</option>
</select>
</form>
<div id="feedbackview"></div>
这是我的ajax
function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}
var http = createObject();
function viewFeedback(condition) {
http.onreadystatechange = function() {
if(http.readyState == 4) {
document.getElementById('feedbackview').innerHTML=http.responseText;
}
http.open("GET",'viewfeedback.php?condition='+condition,true);
http.send(null);
}
}
这是php
$condition = $_GET['condition'];
$db = new db();
$query = $db->query("SELECT * FROM feedback");
$rows = $db->countRows($query);
if($rows != 0) {
$results = $db->getRows($query);
foreach($results as $result) {
extract($result);
echo $name;
}
}