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 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?
  • ¥50 invest生境质量模块
  • ¥15 nhanes加权logistic回归,svyglm函数