I have this ajax check to find out if a name is found or not. It works great when detecting data, but when it returns nofound, I have to send it again to call it.
Does anyone have a suggestion or a better solution for this?
$('#formletter').submit(function() {
var name = $('#name').val();
if ($.formLoading != false) {
$.ajax({
type: 'POST',
url: "submit_ajax_contents.php",
data: "namecheck="+name,
success: function(data) {
if(data == 'nofound'){
$.formLoading = false;
$('#formletter').submit();
}else{
alert('found');
$.formLoading = true;
}
}
});
return false;
} else {
return true;
}
});
});
Many thanks:)
source
share