Correct handling of jqXHR error response

Also provide a meaningful message in the 'result' attribute of the response json.