【发布时间】:2011-04-16 12:44:43
【问题描述】:
我想从 HTML 向代码点火器中的控制器发送包含特定表单信息的帖子。我希望控制器处理信息并在 div 中加载某个页面。这是我的代码。我想我应该使用 .html 之类的东西?我不太清楚,我不明白
控制器
function search_friend(){
//this function gets text from text field and searches for a user and returns all users similar to this dude
// $this->input->post($searchFriendForm);
// $this->input->post($searchFriendText);
$this->load->model('userProfile_m');
$people = $this->userProfile_m->get_user_by_name($this->input->post($searchFriendText));
$this->load->view('addFriendSearchResult',$people);
}
html中的表单
<form method="post" action="" name="searchFriendForm" id="add-friend-search">
<input type="text"/ name="searchFriendText">
<input type="button" class="small green button" id="add-friend-button" />
</form>
jquery 函数
$("#add-friend-button").click(function(){ //start click
$.post("<?php echo site_url('userProfile/search_friend'); ?>", $("#add-friend-search").serialize());
$("#insert-activity").load("<?php echo base_url().''?>system/application/views/addFriendSearchResult.php");
$("#add-friend-search").slideUp("slow",function(){});
}); //end click
【问题讨论】:
标签: php jquery ajax codeigniter