Método do model que captura os dados do db:
function obter_noticias() {
$start = $this->db->escape_str($this->input->post('start'));
$end = $this->db->escape_str($this->input->post('end'));
$sql = "SELECT * FROM noticias WHERE noticias.data >= $start AND noticias.data <= $end ORDER BY noticias.data ASC";
$query = $this->db->query($sql);
$array = $query->result_array();
return $array;
}
Método do controller
que retorna o objeto json
function Test_Function(){
$noticias = $this->model->obter_noticias();
$obj = NULL;
//The cat's leap: criar o objeto para a variavel 'events'
foreach ($noticias as $i) {
$obj[] = [
'title' => $i['titulo'],
'start' => $i['data']
];
}
echo json_encode($obj);
exit();
}
javascript:
$(document).ready(function(){
$('#calendar').fullCalendar({
//alert('Teste de carregamento FullCalendar');
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay,listWeek,'
},
editable: false,
navLinks: true,
selectHelper: true,
events: {
url: 'dashboard/Test_Function',
type: 'POST',
data: {
value1: 'aaa',
value2: 'bbb'
},
success: function(data) {
console.log(data);
},
error: function() {
alert('Erro ao carregar eventos!');
},
}
});
});