I have some jQuery that looks like this:
$.ajax({
type: "POST",
url: "/problems/vote.php",
dataType: "json",
data: dataString,
success: function(json)
{
// ? :)
}
error : function()
{
alert("ajax error");
}
});
when I am writing my AJAX code, in case of some validation or database errors, I want to stop execution and return to the jQuery error block. What do I have to do in the PHP AJAX code in order to return things to the error block instead of the success block?
Thanks!!
you’d have to use the success function and capture what is returned for example:
you’ll only use
error:if there is a problem with the AJAX request