We have a JavaScript search script that pulls data from the Bing API. However, when no results are found for the users query, it just displays a blank page. How can we make the script display a no results message such as “Nothing found.”?
ajax({
type:"GET",
url:"http://api.bing.net/json.aspx?appId=APPID&query=QUERY&sources=web&adult=strict&web.count=10&cc=en&jsontype=callback&jsoncallback=?",
dataType:"jsonp",
success:function(a){
$ID("results").innerHTML="<h2>Search</h2>";
for(var c=0;c<a.SearchResponse.Web.Results.length;c++){
var d=a.SearchResponse.Web.Results[c];
$ID("results").innerHTML+="<a href=\""+d.Url+"\" id=\"result\"><div id=\"title\">"+d.Title+"</div><div id=\"url\">"+d.DisplayUrl+"</div>"+d.Description+"</a>"
}
}
})
Probably not what you want, but it’s more or less is what you asked for.