I'm trying to update the flag
variable value when there is an error but it doesn't update even when there is error:
var flag = 0;
var index = $(this).attr('data-index');
// Validate User/Client Data When Next Button is clicked (Up or DOWN)
if(index == 2){
e.preventDefault();
$.ajax({
url: '<?php echo $this->CxHelper->Route('quiz-client-details'); ?>',
type: 'POST',
data: $('#signup-form').serialize(),
dataType: 'JSON',
success: function(data) {
if (data.status == 'success') {
console.log(data.status);
}
},
error: function(data){
$('.error-box').html(data.responseText);
flag = 1;
}
});
}
index++;
console.log(flag);
I'm trying to update flag value here:
error: function(data){
$('.error-box').html(data.responseText);
flag = 1;
}
But in console the flag
value is 0!
Thanks