Welcome Guest, Not a member yet? Register   Sign In
Jquery post help
#14

[eluser]vitoco[/eluser]
i've added son lines
Code:
function deletePost()
    {
        if($this->session->userdata('candidate_id'))
        {
            if($this->input->post("diss_id"))
            {
                $d_id = $this->input->post('diss_id');
                $post_id = $this->input->post('post_id');
                $parent = $this->input->post('parent');
                $delete = $this->discussionmodel->removePost($d_id,$post_id,$parent);
                echo $delete;
            }
            // NO RETURN DEFINED -> -1
            else
            {
                echo '-1' ;
            }
        }
        else
        {
            redirect('/login','location');
        }
    }

My model function
Code:
function removePost($diss_id,$post_id,$parent)
    {
        $moodle = $this->load->database('moodle',true);
        $userid = $this->session->userdata('user_id');
        $first_post = $this->getParent($diss_id);
        $mess = 1;
        if($first_post == $parent)
        {
            $delete_post = "delete from mdl_forum_posts where
             id = $post_id and
             discussion = $diss_id";
            $sql = $moodle->query($delete_post);
            if($sql)
            {
                $data = 1;
            }
            else
            {
                $data = 2;
            }
        }
        else if($first_post == $post_id)
        {
            $query = "delete from mdl_forum_posts where id = $post_id and discussion = $diss_id";
            $sql1 = $moodle->query($query);
            $delete = "delete from mdl_forum_discussions where firstpost = $post_id and id = $diss_id";
            $dele = $moodle->query($delete);
            $delete_diss = "delete from pl_discussion where discussion_id = $diss_id";
            $qry = $moodle->query($delete_diss);
            
            if($query && $dele && $qry)
            {
                $data = 3;
            }
            else
            {
                $data = 2;
            }
        }
        // RETUDN -1
        else
        {
            return -1 ;
        }
        return $data;
    }

see if the $.post it's getting a '-1' string as return

-------------
Sorry no demo site available. and one more doubt i have is.Is there any limit for using Jquery $.post in a single jquery file ?

there's no limit, cause it's a function, you can call it as many times as you want.


Messages In This Thread
Jquery post help - by El Forum - 08-21-2010, 12:02 AM
Jquery post help - by El Forum - 08-21-2010, 12:48 AM
Jquery post help - by El Forum - 08-21-2010, 12:54 AM
Jquery post help - by El Forum - 08-21-2010, 01:15 AM
Jquery post help - by El Forum - 08-21-2010, 01:41 AM
Jquery post help - by El Forum - 08-21-2010, 04:48 AM
Jquery post help - by El Forum - 08-22-2010, 11:00 PM
Jquery post help - by El Forum - 08-22-2010, 11:39 PM
Jquery post help - by El Forum - 08-22-2010, 11:43 PM
Jquery post help - by El Forum - 08-22-2010, 11:47 PM
Jquery post help - by El Forum - 08-22-2010, 11:50 PM
Jquery post help - by El Forum - 08-22-2010, 11:55 PM
Jquery post help - by El Forum - 08-22-2010, 11:58 PM
Jquery post help - by El Forum - 08-23-2010, 12:08 AM
Jquery post help - by El Forum - 08-23-2010, 12:16 AM
Jquery post help - by El Forum - 08-23-2010, 01:35 AM
Jquery post help - by El Forum - 08-24-2010, 02:40 PM



Theme © iAndrew 2016 - Forum software by © MyBB