I have a Google Instant style search script written in jQuery which queries a PHP file. Currently, when no results are found, the PHP file returns no HTML code so the script is blank. How can I make it so my jQuery script displays a message when no HTML code is returned?
My code jQuery code is:
$(document).ready(function(){
$("#search").keyup(function(){
var search=$(this).val();
var query=encodeURIComponent(search);
var yt_url='search.php?q='+query+'&category=web';
window.location.hash='search/'+query+'/1/';
document.title=$(this).val()+" - My Search Script";
if(search==''){
window.location.hash='';
document.title='My Search Script';
}
$.ajax({
type:"GET",
url:yt_url,
dataType:"html",
success:function(response){
$("#result").html(response);
}
});
});
});
Change this line
To
Hope this helps.