Possible Duplicate:
submit form does not stop in jquery ajax call
I have a form:
<form id="orderForm" onsubmit="return prepareOrder(this);" action='@ConfigurationManager.AppSettings["EpayLogonUrl"]' method="POST">
And prepareOrder function:
function prepareOrder(form) {
$('.wizard_next_step').attr('disabled', 'disabled');
$('.wizard_next_step').addClass('disabled');
$('.wizard_prev_step').attr('disabled', 'disabled');
$('.wizard_prev_step').addClass('disabled');
$.ajax({
type: 'POST',
url: '/Pay/CreateOrder',
success: function (response) {
if (response.IsSuccess) {
alert('2');
$("input[type=hidden][name=Signed_Order_B64]").val(response.Message);
} else {
alert('1');
toastr.options.timeOut = 10000;
toastr.info(response.Message);
return false;
}
},
error: function () {
return false;
},
async: false
});
}
The problem in that submit not stoping when IsSuccess equal false. For test, I insert alert and alert shows properly (1), but form submit anyway. Where is a problem?
Your ajax call is returning false, but your
prepareOrdermethod is not.Try returning false outside of the ajax call: