How to redirect page after click on Ok button on sweet alert?

前端 未结 12 911
别跟我提以往
别跟我提以往 2020-12-10 01:15

I am able to display sweet alert after the page refresh but I have to click on Ok button which I am getting on sweet alert to redirect the page.Please help me in this.

12条回答
  •  一个人的身影
    2020-12-10 02:07

    I wasn't able to do that with any swal(sweatAlert) default callback function, so I forced with jquery, got the Ok button class inspecting the element in chrome an made something like this:

    
    

    The 'Ok' alert in function(isConfirm) was just a test to see if it would get into this function, if so I should be able to redirect from there, but I wasn't...

    So I used jQuery to determine if the button "OK" of swal was clicked by getting it class: ".swal2-confirm' then I could redirect with success...

    Hope this helps you all !

    PS: I am using php echo to run the script, I din't have to leave php to run it, just use single quotes and you're done !

提交回复
热议问题