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>
4

3 回答 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;
于 2013-08-28T05:15:31.943 回答
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    
}
于 2013-08-28T05:18:16.650 回答
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
}
于 2013-08-28T05:20:52.663 回答