Php 向控制器发送数据AJAX post数据
我最难将下拉列表的值(如html)发送到我的控制器,这应该非常简单 选择下拉列表: 我得到bool(false)作为返回值尝试替换Php 向控制器发送数据AJAX post数据,php,codeigniter,jquery,Php,Codeigniter,Jquery,我最难将下拉列表的值(如html)发送到我的控制器,这应该非常简单 选择下拉列表: 我得到bool(false)作为返回值尝试替换 var selection = $(this).find(":selected").html(); 与 您的ajax调用如下 $.ajax({ url: '<?php echo base_url();?>welcome/retrieve_form_template/', async: false, type: 'POST', d
var selection = $(this).find(":selected").html();
与
您的ajax调用如下
$.ajax({
url: '<?php echo base_url();?>welcome/retrieve_form_template/',
async: false,
type: 'POST',
data: {selection : selection},
dataType: 'html',
success: function(data) {
console.log(data);
}
});
$.ajax({
url:“欢迎/检索表单模板/”,
async:false,
键入:“POST”,
数据:{selection:selection},
数据类型:“html”,
成功:功能(数据){
控制台日志(数据);
}
});
请尝试使用jQuery ajax函数进行以下更改
数据:'selection='+selection,相同的结果没有有效的值发送=/您能解释一下发生了什么吗?这里我们为变量选择分配了选择值,该变量选择将发布在您的页面上……就是这样
public function retrieve_form_template()
{
$selection = $this->input->post('selection');
echo var_dump($selection);
}
var selection = $(this).find(":selected").html();
var selection = $(this).val();
$.ajax({
url: '<?php echo base_url();?>welcome/retrieve_form_template/',
async: false,
type: 'POST',
data: {selection : selection},
dataType: 'html',
success: function(data) {
console.log(data);
}
});