这是我的javascript。
$(document).ready(function () {
$("#filters").on('submit', function(e){
e.preventDefault();
start_date = $("input[data-name='fromDate']").val();
end_date = $("input[data-name='toDate']").val();
project = $("select[name='project']").val();
repo = $("select[name='repo']").val();
coder = $("select[name='coder']").val();
$.ajax({
url: '/graph/ajax_filter',
data: {
start_date: start_date,
end_date: end_date,
project: project,
repo: repo,
coder: coder
},
type: 'POST',
dataType: 'json',
success: function(response) {
view = response.view
}
});
});
});
这是我的控制器功能
public function ajax_filter() {
var_dump('hello');die;
$filter = array(
'start_date' => $this->input->post('start_date'),
'end_date' => $this->input->post('end_date')
);
$view = $this->load->view('overview', $filter, TRUE);
$ret = array(
'view' => $view
);
die(json_encode($ret));
}
我正在尝试过滤图表。我从视图中收集的数据就在那里。但是当我尝试使用 ajax_filter 函数时,我无法显示 var_dump