【发布时间】:2017-12-02 19:13:57
【问题描述】:
我是 ajax 新手,我正在尝试查看、添加、编辑和删除 mysql 数据库的数据,而无需刷新选项卡或在此表上使用 ajax:
我已经完成了视图部分,*已编辑,但我不知道如何编辑或删除 *.我知道这是一项很长的任务,但我在互联网上没有找到解决方案..提前谢谢
HTML 代码:
<html>
<head>
<title>View Data Without refresh</title>
<script language="javascript" type="text/javascript" src="script/jquery-git.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
(function() {
$.ajax({
type: "POST",
url: "display.php",
dataType: "html",
success: function(response){
$("#responsecontainer").html(response);
}
});
});
});
</script>
</head>
<body>
<fieldset><br>
<legend>Manage Student Details</legend>
<table>
<tr>
<th>ID</th>
<th>Name</th>
<th>Class</th>
<th>Section</th>
<th>Status</th>
</tr>
</table>
<div id="responsecontainer" align="center"></div>
</fieldset>
<input type="button" id="display" value="Add New"/>
</body>
</html>
PHP 显示代码:
<?php
include("connection.php");
$sql = "select * from tbl_demo";
$result=mysqli_query($db,$sql);
echo "<table class='myTable'>";
while($data = mysqli_fetch_row($result))
{
echo "<tr>";
echo "<td width='13.5%'>$data[0]</td>";
echo "<td width='21%'>$data[1]</td>";
echo "<td width='19.5%'>$data[2]</td>";
echo "<td width='24%'>$data[3]</td>";
echo "<td><span class='edit'>Edit</span> | <span
class='delete'>Delete</span></td>";
echo "</tr>";
}
echo "</table>";
?>
【问题讨论】:
-
我没有看到按钮。您的 ajax 代码设置为在文档加载后运行。你的问题标题很模糊。你到底在这里问什么?您遇到的具体问题是什么?
-
我也听不懂问题..
-
有'编辑 |删除'Status'表标题中使用的两个跨度,如果用户单击编辑,则应编辑数据,如果用户单击删除,则应删除数据
标签: javascript php jquery mysql ajax