Здравствуйте. Подскажите, пожалуйста.
Есть такая выборка.
$sth = $db->prepare("SELECT * from users where id=? order by id LIMIT 0,6");
$sth->execute($id);
while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
$data[]= ''.$row['username'].' '.$row['family'].' ';
}
header('Content-Type: application/json; charset=utf-8');
echo json_encode($data);
и сам js код.
$(document).ready(function() {
$(function(){
$display = $('#display');
$('.search').keyup(function()
{
var searchid = $(this).val();
var dataString = 'searc='+ encodeURIComponent(searchid);
if(searchid.length == 0) {
document.getElementById('display').style.display = 'none';
} else {
$.ajax({
type: 'POST',
url: "Templates/class/autocomplete_search.php",
data: dataString,
dataType: 'json',
cache: false,
success: function(html)
{
$display.html(html).show();
}
});
}return false;
});
Подскажите, пожалуйста, как вывести на экран результат?
В firebug показывает, что все работает, но не выводит на экран.
$display.hide();
вместоdocument.getElementById('display').style.display = 'none';