Laravel 5.3
Steam API
Ajax
When you type in input, there is an adjax request that uses the Steam API to select possible search options (live search).
However, too long. The user entered for example Half, and you have to wait 15-30 seconds until he collects all the results where there is a keyword and then only displays.
How to conclude immediately what ajax finds?
function getSteamGames(event) { $('.suggested').html(''); var token = $('input[name="_token"]').val(), gameName = $('#gameName').val(); if(gameName.length >= 4) { $.ajax({ url: '/getsteamgames', type: 'POST', dataType: 'json', data: { 'gameName': gameName, '_token': token, }, }) .done(function(data) { $.each(data, function(index, element) { var gameName = element.name, appID = element.appid; $('.suggested').prepend('<div class="suggestedGame label label-info" data-tag_id="'+appID+'">' + gameName + '</div>'); }); }) .fail(function() { console.log("ERROR"); }); } }