Getting a json response from an ajax function that returns the code below:
["Please enter a Name","Please enter a Email","Please enter a Date","Please enter a message"]
The problem is that my current code will only show the last message, instead of all of the messages.
Jquery code is:
var result = jQuery.parseJSON(response);
console.log(response);
$.each(result, function(key, value){
if(key == 'success') {
// console.log(response);
success.find(".message").text(value);
success.slideDown();
success.delay(4000).fadeOut();
}
else {
// console.log(response);
error.find(".message").text(value);
error.slideDown();
}
})
How can I show each error message separately?
'success'so something isn't right in what you have shown