Trying to do a data search with codeigniter 3, ajax. Here is my ajax:
$('input:radio').on('change',function(){ var value = $(this).data('val'); alert(value); $.ajax({ method:"POST", url:"main/tur_search", data:{value:value}, }).done(function(){ $('.load').load('tur_search'); }); But where ajax sends data:
public function tur_search(){ $keyword = $this->input->post('value'); $this->load->model('Page_models'); if ($keyword == ""){ $data['tours'] = $this->Page_models->get_serach_result($keyword); } else{ $data['tours'] = $this->Page_models->get_turs(); } $this->load->view('tur.php',$data); } Model:
public function get_serach_result($keyword){ print_r($keyword); $array = array('blok_title' => $keyword, 'tur_name' => $keyword); $this->db->like($array); $query = $this->db->get('main_turs'); return $query->result(); }
It turns out there is a div. in inside diva through load the data is loaded (when the page loads). For some reason, my ajaxe does not work $ ('. Load'). Load ('tur_search'); Tell me, how can I do it better?
$keyword == ""then you are looking for something on it. Maybe the opposite - you need to look for when the$keywordnot empty? - u_mulder.load('tur_search')loads the data returned bytur_search. Do you have such a URL? Does he give something away? - u_mulder