I need some help with ajax call, I have problem with async true. So I have form on html page and i am using ajax call to call me the php script that is sending the data to email and then it returns the value back to page and displays notification regarding the value returned. So far everything worked ok with this code:
$.validator.setDefaults( {
submitHandler: function () {
$.ajax({
type: 'post',
url: 'Link - script to send info and returns the value',
data: $('form').serialize(),
async: false,
success: function (result) {
if (result == '1') {
$("#error").hide();
$("#validate").hide();
$("#poslano").show();
}else {
$("#error").show();
}
},
});
}
} );
So after all inputs are correct the form if submitted and this part of ajax script sends the data to script and get the returned value. But if I have async set to false I always get this error back even if form is correct:
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
But if I set async to true, then nothing happens. I just get the error message. How should i resolve this problem ? Many thanks in advance.