I was trying to delete a data from database using jquery and the following script helped me to do so. Now I want to show a jquery confirmation modal(YES: NO) before it finally goes for deleting it. I went through some tutorials to learn how to do that but I couldn’t make those work for me
Please kindly show me how to add the confirmation modal.
Thanks
<script>
$(function(){ // added
$('a.delete').click(function(){
var a_href = $(this).attr('href');
$.ajax({
type: "POST",
url: "<?php echo base_url(); ?>batchlist/delete",
data: "id="+a_href,
success: function(server_response){
if(server_response == '1')
{ alert('MSG');} else {$("#trid_"+a_href).hide('slow'); }
}
}); //$.ajax ends here
return false
});//.click function ends here
}); // function ends here
</script
This is my delete anchor
<a href="<?php echo $row['studentid']; ?>" title="Delete" class="delete" ><img src="<?php echo base_url(); ?>support/images/icons/cross.png" alt="Delete" /></a>
you don’t need jQuery to do this. Javascript will do this just lovelyly:
Simple 🙂