-1

I am using a JQuery confirmation for deleting. When I click the button I need to execute a query.

Here is the code for confirmation:

function DeleteButton () {
    $.confirm({
        title: 'Some Title',
        content: 'Are you sure want to delete ',
        icon: 'fa fa-question-circle',
        animation: 'scale',
        closeAnimation: 'scale',
        opacity: 0.5,
        buttons: {
            'confirm': {
                text: 'Proceed',
                btnClass: 'btn-blue',
                action: function () {

                                }
                            },
                cancel: function () {
                    $.alert('you clicked on <strong>cancel</strong>');
                },                              
            }
        });       
    }

When clicked, I proceed need to execute some PHP code. How do I do it?

lmiguelvargasf
  • 63,191
  • 45
  • 217
  • 228
Nola3191
  • 41
  • 6

2 Answers2

0

you can use "POST" function. first, your variables should placed in Array and then post it to external php file to proceed.

second way: using of URL method to post array to php file. be careful, GET method is not safe as well ass POST method

0
function DeleteButton () {
  $.confirm({
    title: 'Some Title',
    content: 'Are you sure want to delete ',
    icon: 'fa fa-question-circle',
    animation: 'scale',
    closeAnimation: 'scale',
    opacity: 0.5,
    buttons: {
        'confirm': {
            text: 'Proceed',
            btnClass: 'btn-blue',
            action: function () {
              $.ajax({
                url: "delete.php",
                type: "POST",
                data: {'your data'},
                success: function (resp) {
                   alert(resp);
                },
                error: function () {
                    alert("An error has occured!!!");
                }
            });
          }
        },
        cancel: function () {
            $.alert('you clicked on <strong>cancel</strong>');
        },

    }
  });


  }
//delete.php

<?php
  //Your php logic goes here
  echo "Delete process";
?>

Check out this ajax call. you can run your php code using this manner.please note this give you basic idea how to call ajax, you have to implement your logic. Greetings!

Geee
  • 2,217
  • 15
  • 30