0

This is not working in my codeigniter function i have the id and cannot get that id.Please help me. this is my view and i am trying to send my id through the function.

<script type="text/javascript">
    function makeajaxcall(id) {
        //alert(id);
        var r = confirm("Do you want to Delete");
        if (r == true) {
            window.location.href = "<?php echo site_url('controller_d/login/admin_link_delete_user?id='.id);?>";
        } else {
            x = "You pressed Cancel!";
            alert(x);
        }

    }
</script>
1
  • use ajax for call controller function... Commented Aug 28, 2013 at 5:13

3 Answers 3

8

Change this line:

window.location.href = "<?php echo site_url('controller_d/login/admin_link_delete_user?id='.id);?>";

To:

window.location.href = "<?php echo site_url('controller_d/login/admin_link_delete_user');?>?id="+id;
Sign up to request clarification or add additional context in comments.

Comments

0

Try using this

window.location.href = "<?php echo site_url('controller_d/login/admin_link_delete_user/'.id);?>";

assuming that in your controller you have this method

function admin_link_delete_user($id){
     echo $id;// u'll get the id which you are passing through javascript    
}

Comments

0
<script type="text/javascript">
function makeajaxcall(id)
{
      //alert(id);
      var r=confirm("Do you want to Delete");
      if (r==true)
      {
           $.post("<?php echo site_url('controller_d/login/admin_link_delete_user/');?>", {id:id},
           function(data) {
                alert(data+"a");
           }, 'json');
      }
      else
      {
           x="You pressed Cancel!";
           alert(x);
      }

}
</script>  

in controller

function admin_link_delete_user(){
   echo $this->input->post('id');
   //perform your code
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.