error: function(response) {
contactForm.addAjaxMessage(response.responseJSON.message, true);
}
If you take a look at the jQuery documentation for error
in $.ajax
, you'll see that the third parameter to the callback function is a string containing the error message:
error
Type: Function( jqXHR jqXHR, String textStatus, String errorThrown )
A function to be called if the request fails. The
function receives three arguments: The jqXHR (in jQuery 1.4.x,
XMLHttpRequest
) object, a string describing the type of error that
occurred and an optional exception object, if one occurred.
So, try this, instead:
error: function(a, b, response) {
// You can use `a` and `b` if you need them.
contactForm.addAjaxMessage(response, true);
}