php - CodeIgniter - How to return values from an ajax method? -
i trying pass date ajax function , relevant type , title according date separately database.
i have used following model function.
function get_reservation_for_add_popup($date_cal) { $this->db->select('reservations.title,reservations.type'); $this->db->from('reservations'); $this->db->where('reservations.date_cal', $date_cal); $this->db->where('reservations.is_deleted', '0'); $query = $this->db->get(); return $query->result(); }
my controller function following
function get_title_and_type() { $reservation_service = new reservation_service(); $data['reservation_pop_up'] = $reservation_service->get_reservation_for_add_popup($this->input->post('date', true)); echo $data; }
in view want title , type separately particular day. used following ajax function. don't know how return values ajax function , how catch them variables.
var date = $('#date').val(); var title=[]; var type=[]; $.ajax({ type: 'post', url: '<?php echo site_url(); ?>/dashboard/get_title_and_type', data: 'date=' + date, success: function(msg) { return msg; } });
since new ajax great if give me idea.
in ajax change following
data: 'date=' + date,
to
data: {'date' : date},
Comments
Post a Comment