html - Ajax call delete cakephp -
i'm trying use ajax delete delete records that, when clicked, confirms before sending request. record deleted , work problem after deleting nothing change in view until after reload page manually. want show result in view after click "ok" in dialog
my ajax code :
$(document).ready(function() { if($('.confirm_delete').length) { $('.confirm_delete').click(function(){ var result = confirm('are sure want delete this?'); $('#flashmessage').fadeout(); if(result) { $.ajax({ type:"post", url:$(this).attr('href'), data:"ajax=1", datatype: "json", success:function(response){ } }); } return false; }); } });
in view :
echo $this->js->link('delete', array('controller' => 'publications', 'action'=>'delete', $publication['publication']['id']), array('escape' => false, 'class'=>'confirm_delete'));
$(document).ready(function(){ if($('.confirm_delete').length) { $id=$(this).attr('id'); $('.confirm_delete').click(function(){ var result = confirm('are sure want delete this?'); $('#flashmessage').fadeout(); if(result) { $.ajax({ type:"post", url:$(this).attr('href'), data:"ajax=1", datatype: "json", success:function(response){ } }); $('#row'+$id).remove(); } return false; });
} });
for reason $(this).attr('id') not work ... how id of element selected remove have on view :
<div class="box_detail" id="row<?php echo $publication['publication']['id']; ?>">
Comments
Post a Comment