Instead of doing this:
field_errors.join('<br>')
do this:
data.field_errors.join('<br/>')
Since join
is used to join all elements of an array into a string. Hence, it works on the array elements, not string, which is your field_errors
is here.
UPDATE
// Add all the object data into the field_errors array
var field_errors = [];
for (field in data.field_errors) {
field_errors.push(data.field_errors[field]);
}
// Check the console, if the array is correct or not
console.log(field_errors);
// Now join will work on the array element
field_errors.join('<br/>')