发送(view中):
$.ajax({
type : 'post',
url : 'add',
data : {
'nickname':nickname,
'mobile':mobile,
'sex':sex
},
dataType: 'json',
success : function(m){
console.log(m);
}
});
接收(controller中):
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
if (!empty($this->input->post())) {
$this->user->insert_user($this->input->post());
echo json_encode(array('code' => 1, 'msg' => '插入成功!'));
}
}