Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14114

jQuery UI Livesearch works with English, but don't work with Cyrillic characters

$
0
0
Hello, I have a problem with jQuery UI Livesearch - it works perfect with English but do not work with Cyrillic - empty array and I have both in my database. I am using CI 3.1.5 and Firebird 1.5. I guess the problem is in encoding. Here is my code:

My Model:
PHP Code:
public function get_autocomplete($search_data)



$data mb_convert_encoding($search_data"Windows-1251""UTF-8");

// var_dump($data);

$query $this->db1->query("select cl.name
from clients cl
where (cl.name containing  '
$search_data')"); 

//var_dump($query);

return $query->result();



My controller:

PHP Code:
<?php
 
class search extends CI_Controller{

public function 
index()
{
$search_data $this->input->get("input_data");

$results  $this->search_model->get_autocomplete($search_data);

if(!empty( 
$results))
{

$jsonData = array(); //Create array  
            foreach( $results as $row  
            
 
                $jsonData
[] = array(   
                                     
'value' => $row->NAME
                                     
);   
            
 
           $this
->output->set_header("Access-Control-Allow-Origin: *, Content-type: application/json, charset=windows-1251");

echo 
json_encode($jsonData);
}
}

My Ajax:

PHP Code:
$(".addClient").each(function() { 
   
$(this).autocomplete({
  autoFocustrue,
   minLength2  
   source
: function (requestresponse) {
       $.ajax({
           url "<?php echo  site_url('search');?>",
           scriptCharset"windows-1251",
           data : { 'input_data' request.term},
           contentType"application/json; charset=windows-1251",
           dataType"json",
           success: function (data){
            var result = [];
            data.forEach(function (valueindex) {
       result.push({label:value.valuedata:value });
   });
 
   response
(result);
}
      });
   }, 
});
  }); 
I tried mb_convert_encoding, iconv, change charset and nothing. The field in the database is win1251. 
What I am doing wrong?

Viewing all articles
Browse latest Browse all 14114

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>