Sweetalert: uncaught exception: cancel

Created on 1 Dec 2016  路  5Comments  路  Source: t4t5/sweetalert

This error will show when i click "cancel" button in Sweetalert2

swal({ title: menu_title, text: title, input: "text", showCancelButton: true, animation: "slide-from-top", showLoaderOnConfirm: true, inputPlaceholder: lang.write_your_comment, preConfirm: function(inputValue) { return new Promise(function(resolve, reject) { resolve('ok'); }); }) }, allowOutsideClick: false }).then(function(result){ var res = $.parseJSON(result); if(res.status){ swal({ title: lang.thankyou+"!", text: lang.your_feedback_sent, type: "success" }).then(function(confirm){ location.reload(); }); } else{ swal({ title: lang.sorry+"!", text: res.message, type: "warning" }); } });

Most helpful comment

In case someone comes here and gets stuck (because sweetalert != sweetalert2!)

At the end of the swal({...}), add this: .catch(() => swal.close())

Every promise function needs a failure callback.

All 5 comments

when click close icon, it show error too,
uncaught exception: close

In case someone comes here and gets stuck (because sweetalert != sweetalert2!)

At the end of the swal({...}), add this: .catch(() => swal.close())

Every promise function needs a failure callback.

@eminx you saved my day :)

@eminx me too!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rapeflower picture rapeflower  路  4Comments

voodoo6 picture voodoo6  路  4Comments

blackrosezy picture blackrosezy  路  6Comments

girishbr picture girishbr  路  5Comments

yrshaikh picture yrshaikh  路  4Comments