that won't work. Success will trigger after :
if(not_resident){ e.preventDefault(); }
How is it asynchronous? You always need to cancel the button click and then submit the form after successful success:
$('#button').click(function(e) { var $form = $(this).closest('form'); if ($('#ca_resident').prop('checked') == true) { amount=$('#user-amount').val().replace(/[,]/g,""); project_name=$('#project_name').val(); $.ajax({ url: '/main/verify_residence/', type: 'POST', aysnc: false, data: { value: amount, name: project_name }, success: function(data){ $("#verify_residence").html(data); $form.submit(); }, dataType: 'html' }); } e.preventDefault(); });
source share