[英]jquery ajax not posting any data on codeigniter
hy please help me i working on ajax but when i var_dump the data it seem empty 嗨,请帮我,我在Ajax上工作,但是当我var_dump数据时,它似乎是空的
object(stdClass)#20 (0) { }
object(stdClass)#20(0){}
$.ajax({
url: base_url+"process_redeem_check",
data: $("#formId").serializeArray(),
type: "POST",
dataType: "json",
contentType: "application/json",
thats is my javascript code 多数民众赞成在这是我的JavaScript代码
public function process_redeem_check()
{
$input = (object) $this->input->post();
$check = $this->gemstone_model->redeem_check($input);
if ($check->success === TRUE) {
echo json_encode(array('status'=>true));
} else {
echo json_encode(array('status'=>false));
}
}
that my controller please help me i done searching all day 我的控制器请帮我,我整天都在搜索
To use $this->input->post()
initialize the form helper. 要使用
$this->input->post()
初始化表单助手。 You could do that by default in config folder's autoload.php.
您可以默认在config文件夹的
autoload.php.
include form in the the array. 在数组中包含表单。
$autoload['helper'] = array('form');
and use .serialize()
instead of serializeArray()
并使用
.serialize()
而不是serializeArray()
$.ajax({
url: base_url+"process_redeem_check",
data: $("#formId").serialize(),
type: "POST",
dataType: "json",
contentType: "application/json",
And then check you datas your are getting or not 然后检查您的数据是否获得
public function process_redeem_check()
{
$input = $this->input->post();
print_r($input);exit;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.