• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[jquery]Form validation: async true of false?

#1
For some reason form validation does't work when I set up async true, but on the other side if I set up to FALSE then I get in browser console:
Quote:jquery.min.js:4 [Deprecation] 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/.


Code:
function validateForm(form) {
var flag = 0;
var status = false;
var captcha = $('#captcha1').val();
if (captcha == '') {
flag = 1;
var error_text = 'Please enter Image Text.';
$('#capacha_error').html(error_text);
$('#capacha_error').show();
}
if (flag == 1)
{
return status;
} else
{
$.ajax({
type: "POST",
url: "<?= base_url() ?>captcha/checkcaptcha",
global: false,
data: {captcha: captcha},
dataType: 'JSON',
async: true,   ---- DOES'T WORK WITH 'TRUE' OPTION
success: function (data) {
if (data.error)
{
var error_text = 'Captcha Code does not Match Please check.';
$('#capacha_error').html(error_text);
$('#capacha_error').show();
status = false;
} else if (data.success)
{
status = true;
}
}
});
return status;
}
}

Why doesn't it work whith asynchronous request?
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.