$(document).ready(function(e) { $('#btnReset').click(function(){ if(!isValidEmail($('#email').val())){ toastr["error"]("Email Address Required", "Invalid Email Address"); return; } $.ajax({ type: "POST", dataType:'JSON', url: "controllers/login/forgot_account_id.php", data: { email: $('#email').val()}, success: function (data) { if (data.error == "1") { swal.fire({ icon: 'error', html: detail.message }) } else { swal.fire({ icon: 'success', html: 'If we have found your account, you will receive an email containing your account ID soon.' }).then(function(){ window.location.href = '/'; }) } } }); }); });