I'm building a site that uses quite a lot of AJAX requests to sign in, update information and add content.
I am currently using CodeIgnitor for the project and wondering whether a response of either success
"Success, you have updated your profile"
"There was an error updating your profile!"
100 => "Cannot update profile",
101 => "Successfully updated profile",
102 => "Cannot authenticate user",
103 => "Successfully authenticated!",
104 => "Unable to load profile data"
I would say that it really depends on your application and the technologies you are using.
In most cases I would go with the JSON response. Keep in mind that in the near future you will have to worry about translations, you may need to catch different exceptions for the user registration etc.
I think it is better to handle this logic and have messages in backend.