|
|
|
จะกดลบแล้วให้อยู่ในหน้าเดิม ไม่ขึ้นแท็บใหม่ยังไงคะ |
|
|
|
|
|
|
|
Code (PHP)
<?php
$db=new mysqli('host', 'user', 'psw', 'dbname');
if(isset($_POST['type'])){
switch($_POST['type']){
case 'delete':
$db->query($sql='delete from table where id='.intval($_POST['id'])) or die("$sql<br>" . $db->error);
echo 'OK'; break;
case 'insert': //////
echo 'OK'; break;
case 'update': //////
echo 'OK'; break;
}
exit;
}
?>
<!doctype html><html><head>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
$('button').click(function(e){
var tr = $(this).parent().parent();
$,ajax({ type: 'POST', data: {type: 'delete', id: $(this).data('id') }}).done(function(msg){
if(msg == 'OK') $(tr).remove(); else alert(msg);
});
});
});
</script>
</head>
<body>
<table>
<tr><td><button type="button" data-id="1"></td></tr>
<tr><td><button type="button" data-id="2"></td></tr>
</table>
</body>
</html>
|
ประวัติการแก้ไข 2015-08-02 11:34:54
|
|
|
|
Date :
2015-08-02 08:51:52 |
By :
NewbiePHP |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณพี่มากนะคะ -/\-
|
|
|
|
|
Date :
2015-08-02 10:02:08 |
By :
maiahoo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|