javascript - hide a row and a div content after deletion using ajax -
i want fadeout row , div content after deletion in ajax,
my view
<table class="table table-hover text-center" id="mytable"> <tbody> <?php foreach ($get_all_mail $get_all_mails) { ?> <tr onclick="return get_mail_content(<? php echo $get_all_mails['m_id']; ?>)" id="target-list"> <td class="email-title" > <?php echo $get_all_mails['from']; ?> </td> <td class="email-body" > <?php echo $get_all_mails['subject'] ?> </td> <td> <?php echo date('d-m-y', strtotime($get_all_mails['start_date'])) ?> </td> </tr> <?php } ?> </tbody> </table> <div class="content-box" id="content"> </div> my script
function get_mail_content(m_id) { var datastring = 'm_id=' + m_id; var = false; $.ajax({ type: "post", async: false, url: "<?php echo site_url(); ?>admin/get_mail_contents", data: datastring, cache: false, success: function (result) { alert(result); var result = $.parsejson(result); console.log(result.from); var d = new date(result['0']['start_date'] + ' ' + result['0']['start_time']); console.log(d.gethours() + ':' + d.getminutes() + ',' + d.getdate() + '-' + (d.getmonth() + 1) + '-' + d.getfullyear()); $('#content').html(''); $("#content").append('<div class="mail-toolbar clearfix" id="mail_content"> <a href="#" onclick = "return delete_mail(' + result['0']['m_id'] + ')"class="btn btn-danger mrg10l" title="delete"> <i class="glyph-icon icon-trash-o"></i></a> </div></div> </div>'); } }); } function delete_mail(m_id) { var datastring = 'm_id=' + m_id; $.ajax({ type: "post", async: false, url: "<?php echo site_url(); ?> admin/delete_mails", data: datastring, cache: false, success: function (result) { alert(result); $('#content').fadein(400).delay(2000).fadeout(2000); } }); } here when click on table row fire function (get_mail_content) showing content in json format in div id container,with in json format fire function (delete_mail) delete content table row , div.
here in image when click on table row right side div open ,i want when click delete button want hide div , table row(left side)from page.
you this:
$('#content').fadeout('slow', function() { $('#content').html(content); $('#content').fadein('slow'); }); also same ids need hide , fadeout. hope helps.

Comments
Post a Comment