我想使用AJAX標記狀態。我成功地使用AJAX將標誌狀態改爲Active或Deactive,我的目標是在標誌狀態爲1或0時禁用按鈕,問題出現在'if子句'中。該按鈕完全「禁用」在我的桌子上。你能幫助弟弟嗎?激活/取消激活按鈕定位標記
這是我所取得的成就:
$sql= "SELECT * FROM kelas";
$query= mysqli_query($koneksi, $sql);
while ($row=mysqli_fetch_array($query))
{
$id = $row['id'];
$id_kelas = $row['id_kelas'];
$nama_kelas = $row['nama'];
$id_pengajar = $row['id_pengajar'];
$id_siswa = $row['id_siswa'];
$status = $row['status'];
echo "<tr>";
echo "<td><label class=\"control-label\">$nama_kelas</label></td>";
echo "<td>
<a href=\"javascript:void(0)\" rel=\"{$id}\" class=\"btn btn-primary aktifkankelas\" if $status == '1' { echo disabled }>Aktifkan</a>
<a href=\"javascript:void(0)\" rel=\"{$id}\" class=\"btn btn-primary nonaktifkankelas\" if $status == '0' { echo disabled }>Nonaktifkan</a>
</td>";
echo "</tr>";
}
的AJAX
$(".aktifkankelas").click(function(e) {
e.preventDefault();
var id = $(this).attr('rel');
$.ajax({
url: "../admin-app/admin-update-aktifkankelas-app.php",
type: "POST",
crossDomain: true,
data: 'updateaktif='+id,
dataType: 'json',
});
});
$(".nonaktifkankelas").click(function(e) {
e.preventDefault();
var id = $(this).attr('rel');
$.ajax({
url: "../admin-app/admin-update-nonaktifkankelas-app.php",
type: "POST",
crossDomain: true,
data: 'updatenonaktif='+id,
dataType: 'json',
});
});
的回聲?不會工作... –
我已經省略了回聲,它仍然不起作用 – mending3