so this is my console log
{
"name": ["The name field is required."],
"type": ["The type field is required."],
"ceiling_amount": ["The ceiling amount field is required."]
}
how can i put errors in my html like this
console.log(res)
if(res.hasOwnProperty('errors')){
for(var field in res.errors){
var fieldname = field;
var input = $("[name=\""+fieldname+"\"]");
input.closest('.form-group').addClass('has-error')
input.after('<span class="help-block">'+res.errors[field]+"</span>")
}
}else{
window.location.href = res.redirectTo;
}
but this html i use .done() here
but my question is how can i put errors when i use .fail() and thats my response json?