function errorSystem(a) { var t=a.urlForErr; $.ajax( { type:"POST", url:t, data: { username: a.data.u, trxid: a.data.t } }) } $("#submit").click(function() { swal( { title: "Confirmation", text: "confirm data submitted already correct?", type: "warning", showCancelButton: !0, confirmButtonColor: "#DD6B55", confirmButtonText: "Yes, correct!", cancelButtonText: "No, go back!", confirmButtonClass: "btn-danger", closeOnConfirm: false, closeOnCancel: false }, function(a) { a ? $("#formUpload").submit() : swal("Registration Canceled", "You're already canceled the registration.", "error") }) }), $("#formUpload").submit(function(a) { var t = $(this).serialize(), e = $(this).attr("action"); console.log(a); $.ajax({ type: "POST", url: e, data: t, dataType: "json", success: function(res) { if (res.success) { window.location.replace(res.url); } else { swal({title: "Failed", text: res.msg, type: "error"}) } } }), a.preventDefault() }), $("#login").click(function() { $("#formLogin").submit() }), $("#formLogin").submit(function(a) { var t = $(this).serialize(), e = $(this).attr("action"); $.ajax( { type: "POST", url: e, data: t, dataType: "json", success: function(res) { 0 == res.success ? swal({title: "Failed", text: res.msg, type: "error"}) : window.location.replace(res.redirect) }, error:function() { swal({title: "Failed", text: "System error", type: "error"}) } }), a.preventDefault() });