我正在尝试从另一个php页面中检索数据,因为这是一个ajax,这个调用发布数据,但没有给出响应plz建议一些想法,我错了。
这是我的ajax:
function loadedit(){
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("ajaxdiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST","editedit.php",true);
xmlhttp.send();
}
loadedit function will be called on link click.
client.php:
<div class="menuleft">
<a class="menucontent" align="middle" href="http://localhost/DlfIn/home.php">Add</a>
<a class="menucontent" align="middle" onclick="loadedit()">Edit</a>
<a class="menucontent" align="middle" href="http://localhost/DlfIn/home.php">LogOut</a>
</div>
<div id="ajaxdiv">
</div>
editedit.php:
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);
include 'config.php';
$result = mysqli_query($con,"select * from images");
//return the array and loop through each row
if(count($result) > 0){
echo "<table style='width:300px' border='1'>
<tr>
<th></th>
<th>Title</th>
<th>Description</th>
<th>image</th>
<th>select</th>
</tr>";
while ($row = mysqli_fetch_array($result)) {
$title=$row['title'];
$name=$row['name'];
$id=$row['id'];
$description=$row['description'];
echo "<tr>";
echo "<td><input type='checkbox' name='checkbox[]' id='checkbox[]' value=".$id."></td>";
echo "<td><textarea rows='1' >".$title."</textarea></td>";
echo "<td><textarea rows='1' >".$description."</textarea></td>";
echo "<td><img width='100' height='100' src='images/".$name."'</td>";
echo "<td><input type='button' id='sub' value='update'></button><input type='button' id='sub' value='delete'></button></td></tr>";
}
echo "<tr>
<td colspan='4' align='center' bgcolor='#FFFFFF'><input name='delete' type='submit' id='sub' value='Delete'></td>
</tr>
</table>";
}
?>