Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- $(document).ready(function(){
- // csrf token
- $.ajaxSetup({
- headers: {
- 'x-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
- }
- });
- // sweet alert for delete
- $('body').on('click', '.delete-item', function(e){
- e.preventDefault();
- let deleteUrl = $(this).attr('href');
- Swal.fire({
- title: "Are you sure?",
- text: "You won't be able to revert this!",
- icon: "warning",
- showCancelButton: true,
- confirmButtonColor: "#3085d6",
- cancelButtonColor: "#d33",
- confirmButtonText: "Yes, delete it!"
- }).then((result) => {
- if (result.isConfirmed) {
- $.ajax({
- type: 'DELETE',
- url: deleteUrl,
- success: function(data){
- Swal.fire({
- title: "Deleted!",
- text: "Your file has been deleted.",
- icon: "success"
- });
- window.location.reload();
- },
- error: function(xhr, status, error){
- console.log(error);
- }
- })
- }
- });
- })
- })
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement