In my Flask applòication, I am sending an error message as response from an AJAX submit funciton, this way:
return jsonify(message='An error occurred!'),500
In the client I have this function:
$("#submit_button").click(function(){
.....
$.ajax({
url: '/',
data: $("#startcopy").serialize(),
type: "POST",
success: function(response) {
console.log(response);
$("#wait").hide();
alert(response);
},
error: function(request,status, message) {
console.log(request);
$("#wait").hide();
alert("Error\n"+message);
}
});
}
});
But I can't get the error message displayed in the alert box. Where am I wrong?