Javascriptui + PHP + Mysql autocomplete

Asked

Viewed 500 times

0

Good morning guys I’m implementing an autocomplete in a CRM but I’m with a problem gave a searched here and I did not find a solution, so below the description:

I am wanting to make my system more intuitive with auto complete and I am using the following codes:

Controller:

function get_cliente(){
    $this->load->model('commentModel');
    if (isset($_GET['term'])){
      $q = strtolower($_GET['term']);
      $this->birds_model->get_cliente($q);
    }
  }

Model:

function get_cliente($q){
    $this->db->select('cnome');
    $this->db->join('clientes', 'clientes.ccod = comentarios.cliente');
    $this->db->like('cliente', $q);
    $query = $this->db->get('clientes');
    if($query->num_rows() > 0){
      foreach ($query->result_array() as $row){
        $new_row['label']=htmlentities(stripslashes($row['cliente']));
        $new_row['value']=htmlentities(stripslashes($row['ccod']));
        $row_set[] = $new_row; //build an array
      }
      echo json_encode($row_set); //format the array into json data
    }
  }

View: on my system I am using a layout template (layout.php) where within it I load my views as needed (cliente_history2.phtml), in case I am loading the javascript and javascript-filesui.css within the layout.php view and within the cliente_history.phtml view have a Modal, and in this modal is the field that I want to implement the autocomplete. below the codes:

Files being loaded in.php layout:

<head>

<link href=' <?php echo base_url('assets/calendar/fullcalendar.min.css'); ?>' rel='stylesheet' />
<link href='<?php echo base_url('assets/calendar/fullcalendar.print.min.css'); ?>' rel='stylesheet' media='print' />
<script src="<?php echo base_url("assets/plugins/jQuery/jquery-2.2.3.min.js"); ?>"></script>

<link href="assets/js/jquery-ui.min.css" rel="stylesheet" type="text/css" />

Auto complete script path within the view clientes_history2.phtml:

<!DOCTYPE html>
<html lang="en">

<head>

<script type="text/javascript">  
    $(function(){
        $("#cliente").autocomplete({
          source: "comments/get_cliente" // path to the get_birds method
        });
    }); 
</script>

Modal to insert data within the clientes_hystory2.phtml view:

<!-- Modal de inserir-->
<div class="modal fade" id="new_coment" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
       <div class="modal-header  bg-red">
            <button type="button" class="close" data-dismiss="modal" 
aria-label="Fechar"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="modalLabel">Adicionar Comentario</h4>
  </div>
  <div class="modal-body">

 <?php echo form_open('clientes/inserir_coment', 'id="form-comentarios"'); ?>

<form action="" method="GET" ENCTYPE="multipart/form-data">
  <div class="row">
    <div class="form-group col-md-5">
        <label for="nome">Data</label> <input type="text" class="form-control" id="dat" name="dat"
            placeholder="informe uma data " 
            value="<?php echo date('d/m/y') ; ?>">
    </div>     

    <div class="form-group col-md-5">
        <label for="cliente">Cliente</label> <input type="text" class="form-control" id="cliente" name="cliente"
            placeholder="informe o nome do cliente"
            value="<?php echo isset($view_cliente) ? $view_cliente: '' ; ?>">
    </div>
</div>

Below the error that returns me when I type something in the field #modal client: inserir a descrição da imagem aqui

Apache log errors:

[Thu May 04 20:24:37.297382 2017] [ssl:warn] [pid 4508:tid 692] > AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name 
[Thu May 04 20:24:37.380539 2017] [core:warn] [pid 4508:tid 692] AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run? 
[Thu May 04 20:24:37.728286 2017] [ssl:warn] [pid 4508:tid 692] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name 
[Thu May 04 20:24:38.311381 2017] [mpm_winnt:notice] [pid 4508:tid 692] H00455: Apache/2.4.23 (Win32) OpenSSL/1.0.2h PHP/7.0.9 configured -- resuming
 normal operations 
[Thu May 04 20:24:38.311381 2017] [mpm_winnt:notice] [pid 4508:tid 692] AH00456: Apache Lounge VC14 Server built: Jul  1  2016 11:09:37 
[Thu May 04 20:24:38.311381 2017] [core:notice] [pid 4508:tid 692] AH00094: Command line: 'c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache' 
[Thu May 04 20:24:38.313882 2017] [mpm_winnt:notice] [pid 4508:tid 692] AH00418: Parent: Created child process 1904 
[Thu May 04 20:24:39.975894 2017] [ssl:warn] [pid 1904:tid 656] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name 
[Thu May 04 20:24:40.289374 2017] [ssl:warn] [pid 1904:tid 656] AH01909:  www.example.com:443:0 server certificate does NOT include an ID which matches the server name 
[Thu May 04 20:24:40.340911 2017] [mpm_winnt:notice] [pid 1904:tid 656] AH00354: Child: Starting 150 worker threads.
  • Have you tried checking the apache log? these errors are usually logged in by apache

  • updated the post with the bugs in the apache log

  • Apache log errors indicate SSL configuration failure. Your Servername is not equal to the name in the certificate. I don’t think that’s the problem, but fix it. It looks more like the method in model. You already know the method get_client is returning an error (500), just have to figure out what error is this...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.