Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ajax jquery search om
- $("#button-box-1").click(function(event) {
- //alert();
- event.preventDefault();
- //merk
- var autocomplete = $(".autocomplete").val();
- //tipe
- var autocomplete1 = $(".autocomplete1").val();
- $.ajax({
- type: "POST",
- url:site+'/welcome/searchproduct',
- dataType: 'json',
- data: {
- autocomplete: autocomplete,
- autocomplete1: autocomplete1
- },
- success: function(res) {
- if (res)
- {
- $(".box-2").show()
- }
- }
- });
- });
- <!--controller-->
- public function searchproduct()
- {
- //for post caming from
- $autocomplete=$this->input->post('brand');
- $autocomplete1=$this->input->post('tipe');
- $this->db->select('*');
- $this->db->from('li_product_post a');
- $this->db->join('li_brand b', 'b.id_brand=a.id_brand', 'left');
- $this->db->join('li_tipe c', 'c.id_tipe=a.id_tipe', 'left');
- //or where
- $this->db->where('name_brand', $autocomplete);
- $this->db->or_where('name_tipe', $autocomplete1);
- $query = $this->db->get();
- foreach($query->result() as $row)
- {
- $arr['query'] = $keyword;
- $arr['suggestions'][] = array(
- 'value' =>$row->name_tipe,
- 'id_brand' =>$row->id_brand,
- 'id_tipe' =>$row->id_tipe,
- 'product_harga' =>$row->product_harga,
- 'product_toko' =>$row->product_toko,
- 'product_status' =>$row->product_status,
- );
- }
- echo json_encode($arr);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement