Help with JQuery - Confirm

1

Good day forum. Some suggestions to be able to perform the removal execution by means of a jquery confirm.

My deletion is done by php and I intend to execute it under $ .alert ('Prospect Removed'). My question is through which process I can execute my php code so that the elimination is carried out. I have tried with a function and ajax but it does not work for me, some suggestion. First of all, Thanks.

    
asked by Ever 03.10.2017 в 21:12
source

2 answers

0

You're on the right track using JQuery and in fact it should be easy using something like (instead of $ .alert ...):

$.post( "eliminar.php", {id:$("#inputDeIdAEliminar").value} function( data ) {
  if(data=="OK"){
      //tu codigo para eliminar el div o control donde tienes la información
      //del registro eliminado va aquí.
      alert("Registro Eliminado");
  }else{
      alert("Ocurrió el siguiente error: "+data);
  }
});

In your php you would receive:

if(isset($_POST['id'])){
   //todo tu codigo para eliminar el registro.
}
    
answered by 03.10.2017 в 21:25
0

I hope this example serves you:

add this in the js

 function delete()
{
  var x = confirm("estas seguro de eliminar este usuario?");
  if (x){
      return true;
  }else{
    return false;
  }
}

in the html add the function and the enlasas with the click event

<input type="button" Onclick="delete()">

inside the if in the true you can already handle it as you wish if you want to handle it with ajax you can also do it.

    
answered by 03.10.2017 в 21:25