refactor success/error messaging on ajax calls