2016-04-01 23 views
1

aksanıyla iyi çalışmıyor, jquery'den otomatik tamamlamada aksama ile ilgili bir sorunum var. i aksanıyla bir mektup yazarken i gibi bir sonuç "M & aacute; Theus" yerine "matheus" ijquery autocomplete,

feryat

benim kodunu takip i "M Theus?" sahip sonra deşifre etmek utf8_encode değiştirmeye çalıştı

retornar_cliente_processo.php

<?php require_once("conexao/conexao.php"); ?> 
<?php 
$term = trim(strip_tags($_GET['term']));//retrieve the search term that autocomplete sends 

$qstring = "SELECT clienteNome as value,clienteId as id FROM cliente WHERE clienteNome LIKE '%".$term."%' LIMIT 10"; 

$consulta_tr = mysqli_query($conecta, $qstring); 
    if(!$consulta_tr) { 
     die("erro no banco1"); 
    } 

while ($row = mysqli_fetch_array($consulta_tr,MYSQL_ASSOC))//loop through the retrieved values 
{ 
     $row['value']=htmlentities(stripslashes(utf8_encode($row['value']))); 
     $row['id']=(int)$row['id']; 
     $row_set[] = $row;//build an array 
} 
echo json_encode($row_set);//format the array into json data 
?> 

js

$(document).ready(function() { 
    $('#clientes').autocomplete({ 
    source: 'php/retornar_cliente_processo.php', 
    minLength: 1, 

     select: function(event, ui) { 

     $('#clienteId').val(ui.item.id); 
     $('.form-control').removeAttr("disabled"); 
     $('#clientes').attr("disabled", "disabled"); 
     $('#alteraNome').removeAttr("disabled");   
      }, 
     }); } 

html

İşte

<input type="hidden" name="clienteId" id="clienteId" placeholder="ID"> 

     <div class="form-group"> 
      <div class="col-md-12"> 
       <label for="clienteNome" class="control-label">Nome do cliente</label> 

       <div class="input-group"> 
        <input type="text" autocomplete="off" name="clienteNome" id="clientes" class="form-control" placeholder="Nome do cliente" required> 

       </div> 

     </div> 
     </div> 
+1

Baktığınız mı/düşünülen Bu örnekte açıklanan vurgu katlama? http://jqueryui.com/autocomplete/#folding Bence sonuç daha da cazip geliyor. Aksi takdirde, kodlama sorununun nerede meydana geldiğini bilmeye yardımcı olur. Sunucuya geri gönderirken veya veritabanını sorgularken mi? – ficuscr

+0

'utf8_encode()', ISO-8859-1/Latin-1'den UTF-8'e. Latin-1'deki kodlamanın doğru olduğundan emin misiniz? – frz3993

cevap

1

, sen M&Aacute;THEUS yerine MÁTHEUS olsun neden olduğunu) (htmlentities kaldırın:

$row['value']=stripslashes(utf8_encode($row['value'])); 
+0

vay .. Çok teşekkürler. Birçok denemeden sonra bu çözüm size yardımcı olmaktan mutluluk duyar! –

+0

:) –

İlgili konular