Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function(){
- var timerID;
- $('.search__form input[name="s"]').keyup(function(){
- var $thisVal = $(this).val();
- if($thisVal.length == 0)
- {
- $('.search__result-all').hide();
- $('.search__result').hide();
- $('.search__loader').hide();
- $('.search__not-result').show();
- } else {
- if(typeof timerID != 'undefined')
- {
- clearTimeout(timerID);
- }
- $('.search__result-all').hide();
- $('.search__result').hide();
- $('.search__not-result').hide();
- $('.search__loader').show();
- timerID = setTimeout(function () {
- $.get( '/search/?&s=' + $thisVal + '&ajax-search=true', function( data ) {
- //data = JSON.parse(data);
- if(data.length > 0)
- {
- $('.search__result').html(data);
- $('.search__not-result').hide();
- $('.search__result-all > a').attr('href', '/search/?s=' + $thisVal);
- $('.search__result-all').show();
- $('.search__result').show();
- $('.search__loader').hide();
- }
- else {
- $('.search__result-all').hide();
- $('.search__result').hide();
- $('.search__loader').hide();
- $('.search__not-result').show();
- }
- });
- }, 2000);
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement