The biggest issue you have right now, IMO, is that `success` is at the same level of your structure as each individual error. The errors should be grouped into their own level as such:
<?php
exit(json_encode(Array(
'success' => false,
'errors' => Array(
'#errOne' => 'Enter a valid username',
'#errTwo' = 'Enter a valid email',
'#errThree' = 'Enter a valid password'
)
)));
Then you can check for success, and if it's bad iterate the errors:
success: function (data) {
var key,
errors;
if (!data.success) {
errors = data.errors;
for (key in errors) {
if (Object.prototype.hasOwnProperty.call(errors, key)) {
// `key` holds things like '#errorOne'
// `errors[key]` holds things like 'Enter a valid username'
}
}
}
}