我正在尝试使用 location.href 通过传递年份和选项等参数来调用 codeigniter 中的一个函数。问题是如果第一个参数为 null,那么第二个参数也为 null。
var year = $('#year').val();
var option = $('#option').val();
location.href = base_url+'controller/method/'+year+'/'+option;
我正在尝试以这种方式将其放入 Controller
public function export_customer_details($year = '', $option = ''){
}
最佳答案
你可以尝试这个,但我觉得这很奇怪
var year = $('#year').val();
var option = $('#option').val();
if(year != NULL){
location.href = base_url+'controller/method/'+year+'/'+option;
} else {
location.href = base_url+'controller/method/'+'0'+'/'+option;
}
关于javascript - 在 Codeigniter 中无法获取函数参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36027058/