There is a govnod that was written and it displays the data coming in json here it is:
var timeout = null; $('#searchword').bind('textchange', function (event, numberkey) { var keyword = $(this).val() //console.log("это1:" + keyword) if(keyword.length > 3 && timeout == null) { $('#loader').show(); timeout = setTimeout( function(){ timeout = null; var keyword1 = $('#searchword').val(); //console.log("это2:" + keyword1) var d = [] $('#search_suggestion_holder li').detach(); $('div.ui-tooltip').detach(); $.ajax({ url:'auto-complete.php', data:'keyword='+keyword1, dataType:'json', error: function(jqXHR, textStatus, errorThrown) { alert('ошибка, F12'); console.log('jqXHR:'); console.log(jqXHR); console.log('статус:'); console.log(textStatus); console.log('ошибка:'); console.log(errorThrown); }, success: function(d){ //console.log($.isEmptyObject(d)); if (!! $.isEmptyObject(d)){ //console.log("1") var nafin = '<li class="hover-img">Ничего не найдено</li>' $("#search_suggestion_holder").html(nafin) $('#search_suggestion_holder').show(); $('#loader').hide(); } else { //console.log("2") $.each(d, function(i, val) { //console.log(val.icon + val.value); //console.log(i); var descrmin = val.descr.substr(0, 150); //console.log(descrmin) var hoverimg = "img-hover=\"<img src=/shop/medium/" + val.icon+"> <br> "+ descrmin + "\"" var resultat = '<li class="hover-img" title ' + hoverimg + '><img src="/shop/32x32/' + val.icon + '">' + val.value + '</li>' //console.log(resultat) $('#loader').hide(); $(resultat).appendTo("#search_suggestion_holder") //console.log($("#search_suggestion_holder").html()); $('#search_suggestion_holder').show(); $(".hover-img").tooltip({ content: function (event, ui) { return $(this).attr('img-hover'); }, track: true, }); }) } } }); },700); } else if(keyword.length < 1){ $('#search_suggestion_holder li').detach(); $('div.ui-tooltip').detach(); $('#search_suggestion_holder').hide(); var newwrite = '<li class="hover-img">начните вводить</li>' //console.log(newwrite) $("#search_suggestion_holder").html(newwrite) $('#search_suggestion_holder').show(); $('#loader').hide(); } else if(1 > keyword.length < 3){ $('#loader').show(); $('#search_suggestion_holder li').detach(); $('div.ui-tooltip').detach(); $('#search_suggestion_holder').hide(); var min3 = '<li class="hover-img">Введите больше 3 символов</li>' //console.log(min3) $("#search_suggestion_holder").html(min3) $('#search_suggestion_holder').show(); $('#loader').hide(); //console.log($("#search_suggestion_holder").html()); } }) how to realize that if he was in the water of the йцукен he also looked for qwerty and йцукен , I suppose you need to make an array q = й w = ц and so on, if there are simpler solutions, tell me.
UPDATE
Wrote this function:
function Auto(str) { replacer = { "q":"й", "w":"ц" , "e":"у" , "r":"к" , "t":"е", "y":"н", "u":"г", "i":"ш", "o":"щ", "p":"з" , "[":"х" , "]":"ъ", "a":"ф", "s":"ы", "d":"в" , "f":"а" , "g":"п" , "h":"р" , "j":"о", "k":"л", "l":"д", ";":"ж" , "'":"э" , "z":"я", "x":"ч", "c":"с", "v":"м", "b":"и", "n":"т" , "m":"ь" , ",":"б" , ".":"ю" , "/":"." }; for(i=0; i < str.length; i++){ if( replacer[ str[i].toLowerCase() ] != undefined){ if(str[i] == str[i].toLowerCase()){ replace = replacer[ str[i].toLowerCase() ]; } else if(str[i] == str[i].toUpperCase()){ replace = replacer[ str[i].toLowerCase() ].toUpperCase(); } str = str.replace(str[i], replace); } } return str; } But this option works only in one direction (q ---> й) , as without using a duplicate array d: q to make it work in both directions (q <---> й)(й <---> q)
hfwbzhe found aрация, as well as looking for agoproto search forgopro- Alexey Vasilyevjsand be substituted inkeyword1- Alexey Vasilyev