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

adiwithadidas picture adiwithadidas  ·  4Comments

jamieson99 picture jamieson99  ·  3Comments

Lusitaniae picture Lusitaniae  ·  4Comments

Untit1ed picture Untit1ed  ·  5Comments

VoxelNaut picture VoxelNaut  ·  6Comments