简体   繁体   中英

500 (Internal Server Error) jQuery ajax ui autocomplete codeigniter

I'm trying to access data using jQuery ui autocomplete. On my local host it was well done, but when I upload it to my server it doesn't work. I get a console logs that says " http://myweb.com/data/header/lookup?term=PO 500 (Internal Server Error) ".

I'm using codeigniter to build it.

Here's the jQuery:

$("#producttype").autocomplete({
  source: "<?php echo base_url(); ?>data/header/lookup",
  minLength: 2,
  select: function(event, ui) {
    $("#productcode").val(ui.item.code)
  },
  change: function(event, ui){
    if(ui.item == null || ui.item == undefined){
      $("#producttype").val("");
      $("#productcode").val("");
    }
  }
});

Here's the controller:

public function lookup(){
  if (isset($_GET['term'])){
    $q = strtolower($_GET['term']);
    $this->welcome_m->get_word($q,'DESC1','10');
  }
}

Here's the model:

function get_word($q, $col = '', $param=''){

  $query = $this->db->query("SELECT KODE, DESC1 FROM MASTER WHERE $col LIKE '%".$q."%' AND LENGTH(KODE) = $param");

  if($query->num_rows > 0){
    foreach ($query->result_array() as $row){
      $new_row['label']=htmlentities(stripslashes($row['DESC1']));
      $new_row['code']=htmlentities(stripslashes($row['KODE']));
      $row_set[] = $new_row;
    }
    echo json_encode($row_set);
  }
}

I need advice and help to resolve it, please.

double check your servers database, if you are able to connect to the live database remotely, try and use an example of your query on the database itself and see what error occurs.

in your CI index file, change your 'ENVIRONMENT' variable to 'development'

this should allow errors to be displayed.

Try using CI's Active directory

$this->db->select('KODE, 'DESC1')
         ->like($col, $q, 'both')
         ->where('LENGTH(KODE) = '.$param)
         ->get('MASTER');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM