Action function not working in jQuery-confirm

703 Views Asked by At

I am using https://craftpip.github.io/jquery-confirm/#customizing plugin for the popup. I just need a help When user click on Confirm button then why It's not redirecting it? If I used alert(); then it is displaying.

The function is not getting id value.

Would you help me in this?

<!DOCTYPE html>
<html>
  <head>
    <title></title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.0/jquery-confirm.min.css">
  </head>
  <body>
    <?php 
      $delete_id=2;
    ?>
    <a href="javascript:void(0);" onClick="warning('<?php echo $delete_id;?>')" class="cross-cta">
      <i class="fa fa-times" aria-hidden="true"></i>
     </a>
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
     <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.0/jquery-confirm.min.js"></script>
     <script type="text/javascript">
       function warning($id){
         $.confirm({
           title: 'DELETE SELECTED!',
           content: 'Are you sure?.',
           type: 'red',
           typeAnimated: true,
           theme: 'material',
           buttons: {
             tryAgain: {
               text: 'Confirm',
               btnClass: 'btn-red',
               action: function(){
                 window.location='mypage?action=empty&deletekey='+id+'';

               }
             },
             close: function () {}
           }
         });
       }
     </script>
   </body>
</html>
1

There are 1 best solutions below

0
On BEST ANSWER

Finally I found my issue. The issue was function warning($id){ in this line.I used $id instated of id. I have to use like this function warning(id) and it's working perfectly.