-------------
form.html
-------------
<script type="text/javascript">
function del(id){
$.post( "/del", { id: id }, function(data){
var obj = jQuery.parseJSON( data );
if(obj.state=='y'){
alert('刪除完成');
location.reload();
}else if(obj.state=='s'){
alert('無法刪除,該底下尚有子資料');
}else{
alert('刪除失敗');
}
});
}
</script>
<input type="button" name="button4" value="刪除" onclick="del('100')">
-------------
php
-------------
<?php
$json_res = array('error' => 0, 'state' => '', 'mes' => '');
$json_res['state'] = 'y';
$json_res['mes'] = 'x';
die(json_encode($json_res));
?>
文章標籤
全站熱搜
