$('#search').on('keyup', function() {
var searchKeyword = $.trim($(this).val());
if(searchKeyword!=='')
{
$('.content,h4').empty();
$.ajax({
type: "POST",
url: "searchajax.php",
dataType:"json",
cache:false,
data:{"searchKeyword":searchKeyword},
success:function(data){
if(data==='0')return;//no results
else if(data==='false')
{
$('#searcherror').html('Ουπς κάτι δεν πήγε καλά...στείλε μήνυμα στο support');
}
$.each(data, function() {
........//there are some conditionals here that just categorize the search results....I have removed them since they do not play any role in the solution
})
},
error:function(jqXHR, textStatus, errorThrown){
$('#searcherror').html('Ουπς κάτι δεν πήγε καλά...στείλε μήνυμα στο support');//κοιτάμε τα αρχεία του server σε αυτην την περίπτωση
}
})
}
else
{
$('.content,h4').html('');
}
});