Handle success and errors from Ajax response