fix for when no results found

also tidy up jquery ajax calls to use deferred method syntax