简体   繁体   English

500(内部服务器错误)jQuery ajax ui自动完成codeigniter

[英]500 (Internal Server Error) jQuery ajax ui autocomplete codeigniter

I'm trying to access data using jQuery ui autocomplete. 我正在尝试使用jQuery ui自动完成功能访问数据。 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) ". 我得到一个控制台日志,上面写着“ http://myweb.com/data/header/lookup?term=PO 500 (Internal Server Error) ”。

I'm using codeigniter to build it. 我正在使用codeigniter进行构建。

Here's the jQuery: 这是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' 在您的CI索引文件中,将“环境”变量更改为“开发”

this should allow errors to be displayed. 这应该允许显示错误。

Try using CI's Active directory 尝试使用CI的Active Directory

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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