Answer the question
In order to leave comments, you need to log in
How to make an output condition on AJAX success?
Hello. There is a PHP code in which if the data in the form is empty, then it sets the error variable to true. It is necessary to make a condition in AJAX upon success, if error = true , then execute a certain section of code. But I have an error somewhere in the AJAX code apparently.
$id=$_POST['id_header'];
if($id=="")
{
$error=true;
}
function headDelete(result,ajax_form,url){
$.ajax({
url: url,
type: "POST",
dataType: "html",
data: $("#header_form").serialize(),
success: function(response){
if (response==true) {
$('#result').addClass('alert alert-danger');
$('#result').html("Поле не заполнено");
}
else
{
$('#result').addClass('alert alert-success');
$('#result').html("Данные удалены успешно");
}
}
});
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question