Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AbdulBazith's avatar

Sweet Alert worked, but it closes within seconds why?

Guys i am working with a project, iam using sweet alert. but it closes immediately

how to solve

this is my code

i used

   <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.0.0/sweetalert.min.js"></script>

in my partials.

i used the below code in my view.blade

@include('sweet::alert')

this is my controller

 Alert::success('Data Deleted successfully');

the message is closed fast why??

0 likes
5 replies
LearnHunter's avatar
 <script src="{{asset('https://unpkg.com/sweetalert/dist/sweetalert.min.js')}}"></script>
use this script on layouts file






1 like
AbdulBazith's avatar

@LearnHunter thankz for your reply.

but still it closes immediately why?

actually warning messages or error messages must stop then only user can see

but it disappears ..

Kindly help ya

tykus's avatar
tykus
Best Answer
Level 104

Can you try explicitly setting the the timeout using autoClose()

 Alert::success('Data Deleted successfully')->autoClose(5000);

Or use the persistent() method if the user should close the alert:

 Alert::success('Data Deleted successfully')->persistent('Dismiss');
1 like

Please or to participate in this conversation.