Shayvard Shayvard - 1 month ago 15
Ajax Question

How do I use Sweet Alert Messages in Laravel 5.2 by Ajax?

I want after the user clicked, Without refresh page, add this product in the basket of goods then show Sweet Alert Messages for the user.

Answer

You simply need to create on click function and then call ajax request with done or success function.

Example:

$('.element').on('click', function() {
    $.ajax({
       method:"method",
       url: url,
       data: {
           ..
       }
    })
    .done(function() {
       //other stuff
       swal('Title','Text','success');
    });
});

Hope it helps.

Comments