drduh44480 2016-06-22 09:44
浏览 70

将带有JQuery的变量传递给Controller - PHP Codeigniter

I am working on a project using PHP Codeigniter. I want to know how can I sent a variable with JQuery to the controller. Below is my code

<script>
 function Reset_User_Password(id){

  $.post("<?=base_url();?>WebAdmin/Reset_User_Password/id", {id: id}, function(page_response)
  {
  $(".modal-body").html(page_response);
  });

 }
</script>

Here I'm first getting the variable 'id' from function parameter. But when I run this code, it return the string 'id' instead of the actual user id from database. I want to view the user id. Below is my function from the controller..

public function Reset_User_Password()
{
$data['admin_id'] = $this->uri->segment(3);

$this->load->view('admin/user/reset_user_password', $data);
}
  • 写回答

3条回答 默认 最新

  • dongyirong3564 2016-06-22 09:47
    关注

    Send data by POST method is not append in url as GET method. So you can't get is using $this->uri->segment().

    Instead use

    $data['admin_id']=$this->input->post('id');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作