CodeIgniter Forums
how to delete my entry in ajax way - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: how to delete my entry in ajax way (/showthread.php?tid=43589)



how to delete my entry in ajax way - El Forum - 07-17-2011

[eluser]Wondering Coder[/eluser]
Hello to all CI fans,

I'm having a bit of trouble in implementing it using ajax call. What I want is to delete an entry/data in ajax. I know that I can achieve this using jQuery library, but I'm pretty novice in writing codes in javascript.

my controller function
Code:
function delete()
    {
        $item = $this->input->post('item');
        if($message_data != NULL) {
            $this->db->delete('messaging',array('messaging_id'=>$item));
        } else{
            redirect('messaging/view');}
    }

my view
Code:
<div align='right' style='float: right;'><a href='' id='del_comment' class='del_comment'></a></div>



how to delete my entry in ajax way - El Forum - 07-17-2011

[eluser]Aken[/eluser]
Read into the jQuery post() function, which is a shorthand method of using the jQuery ajax function but defaulting to POST values instead of GET. http://www.jqapi.com/#p=jQuery.post


how to delete my entry in ajax way - El Forum - 07-18-2011

[eluser]IgnitedCoder[/eluser]
You could also try XAJAX, I used it to call controller methods all the time. See: http://ellislab.com/forums/viewthread/182897/

Pretty straight forward to ajax deletes...

Hope it helps.