Ajtak
Ajtak

Reputation: 3

Jquery - Confirm dialog - work php code

I have a question regarding jquery. My code looks like this:

 <button id="callConfirm'.$row['id'].'">DEL</button>


    <div id="dialog" title="Realy?">
 Realy delete '.$row['marks'] .' s váhou   '.$row['weight'] .' z   '.$row['id']  .' ?
</div>​

 <script type="text/javascript">
$("#dialog").dialog({
 autoOpen: false,
modal: true,
 buttons : {
    "Opravdu" : function() {

   alert("You have confirmed!");        },
    "Ne" : function() {
      $(this).dialog("close");
    }
  }
});

$("#callConfirm'.$row['id'].'").on("click", function(e) {
e.preventDefault();
$("#dialog").dialog("open");  
});
 </script>'  

And I needed to click on in order to Opravdu execute delele.php script that looks like this:

 <?php
 include 'conn.php';
 $back = urldecode($_GET['back']);
 $id = mysql_real_escape_string($_GET['id'] * 1);
 mysql_query("DELETE FROM znamky WHERE id=$id");
 ?>

Upvotes: 0

Views: 458

Answers (1)

mplungjan
mplungjan

Reputation: 177684

"Opravdu" : function() {
  $.get("delete.php?id=...&back=...",function(data) {
   alert(data);
  });
}

where data is returned from the delete

Here is how you might want to pass the ID to the gialog

jquery-ui, Use dialog('open') and pass a variable to the DIALOG

Upvotes: 1

Related Questions