cant delete a record, total n00b here.

hola !

i am very very new to ajax/CI, so please be gentle Wink

i am trying to delete a record from my table and also have the nice animation to visually remove the record from the page,of course, i should make the actual record deletion work before moving on to the animation thingie, but im stuck and cant get it to delete records
please help Smile

this makes the "delete" links
<?= anchor('#', 'borrar', array('class' =>'borrador', 'id'=>$res->img_id));?>

this is my jQuery (in the view file)
$(document).ready(function() {
    $("a.borrador").click(function (event) {
        event.preventDefault(); // deshabilita el comportamiento de la liga.
  if (confirm('esto borrar√° la img, de acuerdo? ')){    
        // usuario dijo si a la pregunta.
               var del_id = $(this).attr('id');
               $.post("index.php/moderation/borrar", {item_id : del_id},  function(data){
                       // succcess??
    }); }
});    });

this is my controller (simplified)

class Moderation extends Controller {

    function Moderation()

    function borrar() {
     $this->db->delete('gallery_imgs', array('img_id' => $_POST['item_id']));


use firebug for javascript debugging

[quote author="flaky" date="1262919720"]use firebug for javascript debugging[/quote]
right, firebug..:/

do you think its a javascript problem ??

I can't find a problem in the php code, I'm assuming it's a javascript bug

ok, sorry to be thick here, but i dont know what im looking for in firebug,

or where to look..


look in the console (after turning on firebog)
if there are any javascript error, the console will show them

$.post("index.php/moderation/borrar", {item_id : del_id},  function(data){

This is posting to a relative address. Make sure you're not posting to

that was it... Tongue

thanks Smile

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme ¬© 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.