1
我试图通过ajax请求获取记录。我设法从表中获取所有记录,但现在我想将开始日期和结束日期发送给控制器,以便仅从该时间间隔获取记录。完整日历和CodeIgniter发送开始日期和结束日期
我到目前为止有:
脚本:
events: {
url: 'http://localhost/cms/calendar/get_calendar_ajax',
type: 'POST',
cache: true,
},
控制器:
public function get_calendar_ajax() {
$response = json_encode($this->Calendar_model->getRecords());
echo $response;
}
型号:
public function getRecords() {
$data = $this->db->select()
->from('fullcalendar')
->get()->result();
return $data;
}
我曾尝试:
控制器:
$response = json_encode($this->Calendar_model->getRecords($_GET['start'], $_GET['end']));
型号:
public function getRecords($start, $end) {
$data = $this->db->select()
->from('fullcalendar')
->where('start >=', $start)
->where('end <=', $end)
->get()->result();
return $data;
}
,但没有运气..
检查控制台上的参数,您可以看到开始和结束参数。 – 2015-04-03 08:43:12
@Franky我做到了......问题发送到控制器... – George 2015-04-03 08:58:48
哦!我明白了。日期是未格式化的,首先格式化它们,并在你的模型中传递像这样的公共函数getRecords(start,end){}'并应用条件 – 2015-04-03 09:08:12