Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
- class Autocomplete extends CI_Controller {
- public function __construct()
- {
- parent::__construct();
- $this->load->model("Mautocomplete");
- $this->load->library('form_validation');
- }
- public function index()
- {
- $data['listKategori'] = $this->kategori_model->getAllKategori();
- $header = array(
- 'title' =>'Welcome to my Website'
- );
- $content = array(
- 'article' =>'Lorem Ipsum Dolor Sit Amet'
- );
- $data['data_to_load'] = array($header,$content);
- $data['tmp_file']='pembelian/input';
- $this->load->view('index',$data);
- }
- function lookup(){
- // process posted form data (the requested items like province)
- $keyword = $this->input->post('term');
- $data['response'] = 'false'; //Set default response
- $query = $this->MAutocomplete->lookup($keyword); //Search DB
- if( ! empty($query) )
- {
- $data['response'] = 'true'; //Set response
- $data['message'] = array(); //Create array
- foreach( $query as $row )
- {
- $data['message'][] = array(
- 'id_suplier'=>$row->id_suplier,
- 'value' => $row->nama,
- ''
- ); //Add a row to array
- }
- }
- if('IS_AJAX')
- {
- echo json_encode($data); //echo json string if ajax request
- }
- else
- {
- $header = array(
- 'title' =>'Welcome to my Website'
- );
- $content = array(
- 'article' =>'Lorem Ipsum Dolor Sit Amet'
- );
- $data['data_to_load'] = array($header,$content);
- $data['tmp_file']='pembelian/input';
- $this->load->view('index',$data);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement