Reputation: 17
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>
Upvotes: 0
Views: 17060
Reputation: 1214
<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
}
Upvotes: 0
Reputation: 662
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
}
Upvotes: 0
Reputation: 4250
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;
Upvotes: 8