Add onSearchError callback for handling AJAX failures

This PR allows handling AJAX failures through a new `onSearchError` callback. I tried to adhere to both the libraries as well as jQueries standard method signatures.