I am using jquery 1.11.2 and i am trying to make a ajax async call because i am validating a form.
Here is my code
<form name="form1" id="form1" method="post" action="/payment/payment.php"
onsubmit="return validateForm();">
</form>
function validateForm()
{
data = $('form#form1').serialize();
$.ajax({
type: "POST",
dataType: "json",
url: "/validate.php",
data: data,
async: false,
,success: function (j) {
if(j.error)
{
form_valid=false;
}
if(j.success)
{
form_valid=true;
}
}//success
});//ajax
if(!form_valid){
return false;
}
return true;
}
and because async : false is deprecated the function first return and the gets the ajax response.
The jquery says : "As of jQuery 1.8, the use of async: false with jqXHR ($.Deferred) is deprecated; you must use the success/error/complete callback options instead of the corresponding methods of the jqXHR object such as jqXHR.done() or the deprecated jqXHR.success()."
but i don know how to do this, have search all over but i have not find any solution
How can i make it async or write any other approach that will actually solve my problem
Thanks