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

[eluser]Techno Heart[/eluser]
Ya its empty string.But the same function i have used already in two places.there its working fine ..here am facing this issue...i echo the returned valued in my controller class.but its still returning empty string.you want to look at my model and controller classes ?
#12

[eluser]vitoco[/eluser]
post it, there's a demo site that i could check ?
#13

[eluser]Techno Heart[/eluser]
My controller function
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;
            }
        }
        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;
            }
        }
        return $data;
    }

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 ?
#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.
#15

[eluser]Techno Heart[/eluser]
Ya i added those lines sir. The query executes actually but its returning empty string.same alert i am getting.
#16

[eluser]Techno Heart[/eluser]
Is there any chance for the function to deviate to another function in case of usage of same variables in both functions.
#17

[eluser]InsiteFX[/eluser]
There is a problem with ajax calls using sessions if you
search the forms you should find the solution, not sure
where it is.

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB