1
You’ve defined a global JS variable somewhere called msg
.
If you want to refer to the data returned by the Ajax error, you need to accept it as a parameter in your fail function:
.fail(function(jqXHR, textStatus, error) {
alert(jqXHR.responseText);
})
Source:stackexchange.com