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');
    
    评论

报告相同问题?

悬赏问题

  • ¥50 NT4.0系统 STOP:0X0000007B
  • ¥15 想问一下stata17中这段代码哪里有问题呀
  • ¥15 flink cdc无法实时同步mysql数据
  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。