[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.