I have the swal function working code but when i click cancel without doing, it is going into ajax call which i do not want to
$(document).on('click','.addon',function() { Swal.fire({ title: 'Provide Your Email Address', html: `<input type="email" name="emailaddress" id="emailaddress"> `, confirmButtonText: 'Yes', showCancelButton:true, focusConfirm: false, allowOutsideClick:false, preConfirm: () => { const emailaddress = Swal.getPopup().querySelector('#emailaddress').value; if (!emailIsValid(emailaddress)) { Swal.showValidationMessage(`Please enter correct Email`) } return { emailaddress: emailaddress } }, didDestroy: () => { $(this).prop('checked',false); return; - if i cancel, it should just quit and not go into tthen, } }).then((result) => { var data = 'emailaddress=' + Swal.getPopup().querySelector('#emailaddress').value $.ajax({ url: 'submission.cfm', data: data, type: 'POST', success: function(data) { var sdata = jQuery.parseJSON(data); if($.trim(sdata.status) == 1) { swal.fire({ title:"Cool", text: sdata.message, type:"success", confirmButtonText: 'OK' }).then(() => { window.location.reload(); }); }else { var err = sdata.message; swal.fire("Oops...", err, "error"); } } }); }) });
the above code works but when i click cancel, it still goes into the ajax then, but i do not want it to go there, am i missing anything
https://stackoverflow.com/questions/65866442/issues-with-swal-destroy-function January 24, 2021 at 09:52AM
没有评论:
发表评论