我最难将下拉列表的值(作为 html)发送到我的控制器,应该非常简单..
选择下拉菜单:
<select id="form_selection">
<option value="Home School">Home School</option>
<option value="teem">teem</option>
</select>
Javascript
<script>
$(document).ready(function(){
$('#form_selection').change(function() {
var selection = $(this).find(":selected").text();
console.log(selection);
$.ajax({
url: '<?php echo base_url();?>welcome/retrieve_form_template/',
async: false,
type: 'POST',
data: selection,
dataType: 'html',
success: function(data) {
console.log(data);
}
});
}); //end ajax
});//end function
</script>
控制器:
public function retrieve_form_template()
{
$selection = $this->input->post('selection');
echo var_dump($selection);
}
我得到 bool(false) 作为返回值