ajax post的codeigniter问题
我尝试使用Ajax调用控制器的3个参数,但它给了我错误,缺少参数1、2和3,我知道Codeigniter只接受1个参数,所以我尝试在函数中添加:ajax post的codeigniter问题,ajax,codeigniter,post,Ajax,Codeigniter,Post,我尝试使用Ajax调用控制器的3个参数,但它给了我错误,缺少参数1、2和3,我知道Codeigniter只接受1个参数,所以我尝试在函数中添加: $calibracao_data = $this->uri->segment(3); $user_a_drop = $this->uri->segment(4); $status = $this->uri->segment(5); 但是什么都没用,我也在函数中回显变量,没有成功。 更改了配置文件:$config['
$calibracao_data = $this->uri->segment(3);
$user_a_drop = $this->uri->segment(4);
$status = $this->uri->segment(5);
但是什么都没用,我也在函数中回显变量,没有成功。
更改了配置文件:$config['allowed_uri_chars']='a-z 0-9~%:&\-';什么也没有
ajax的代码:
<script>
function get_active(calibracao_data, user_a_drop, ativo){
var fieldcal = $("input#calibracao_data").val();
var field1 = fieldcal.replace("/", "-");
var field2 = $("select#user_a_drop").val();
var field3 = ativo;
jQuery.ajax({
url: "<?php echo base_url().'instrumentos/get_proximocal_cliente_status/'; ?>",
data: { field1: field1, field2: field2, get_status: field3 },
success: function(g) {
//alert (g);
$(".post_table").html(g);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("some error");
}
});
};
请帮忙。试试看
$calibracao_data = $this->input->get('field1');
$user_a_drop = $this->input->get('field2');
$status = $this->input->get('field3');
或者将method:POST、property添加到AJAX对象
如果您无法意识到所有后果,请不要更改配置文件中的任何内容,例如允许的chars参数
var param = {
fieldcal : $("input#calibracao_data").val(),
field1 : fieldcal.replace("/", "-"),
field2 : $("select#user_a_drop").val(),
field3 :ativo
}
$.ajax({
type: "POST",
url: "<?=base_url()?>.'instrumentos/get_proximocal_cliente_status",
data: param,
cache: false,
success: function(rs)
{
$(".post_table").html(rs);
},
}
});
您好,请检查上面的代码,这对我很有用。您不是在ajax中创建uri段。。。。您正在创建不同的查询字符串。还要注意从控制器方法中删除参数
var param = {
fieldcal : $("input#calibracao_data").val(),
field1 : fieldcal.replace("/", "-"),
field2 : $("select#user_a_drop").val(),
field3 :ativo
}
$.ajax({
type: "POST",
url: "<?=base_url()?>.'instrumentos/get_proximocal_cliente_status",
data: param,
cache: false,
success: function(rs)
{
$(".post_table").html(rs);
},
}
});