Advertisement
Guest User

Untitled

a guest
Feb 17th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. <td><button type="button" class="delete" onclick="deleteRow(this)">Delete</button></td>
  2.  
  3. function deleteRow(r) {
  4.  
  5. if (confirm('Are you sure you want to delete this entry?')) {
  6. var i = r.parentNode.parentNode.rowIndex;
  7. document.getElementById("skuTable").deleteRow(i);
  8. }
  9.  
  10.  
  11. request = $.ajax({
  12. type: "POST",
  13. url: "delete.php",
  14. data: "Group_ID="+i
  15. });
  16.  
  17.  
  18. request.done(function (response, textStatus, jqXHR){
  19. if(JSON.parse(response) == true){
  20. console.log("row deleted");
  21. } else {
  22. console.log("row failed to delete");
  23. }
  24. });
  25.  
  26. // Callback handler that will be called on failure
  27. request.fail(function (jqXHR, textStatus, errorThrown){
  28. // Log the error to the console
  29. console.error(
  30. "The following error occurred: "+
  31. textStatus, errorThrown
  32. );
  33. });
  34.  
  35. // Callback handler that will be called regardless
  36. // if the request failed or succeeded
  37. request.always(function () {
  38.  
  39. });
  40.  
  41.  
  42. }
  43.  
  44. <?php
  45.  
  46. $SKU_Group = $_POST['SKU Group'];
  47. $Group_ID = $_POST['Group_ID'];
  48.  
  49. $host="xxxxxxxxxx";
  50. $dbName="xxxxxx";
  51. $dbUser="xxxxxxxxxxxx";
  52. $dbPass="xxxxx";
  53.  
  54. $pdo = new PDO("sqlsrv:server=".$host.";Database=".$dbName, $dbUser, $dbPass);
  55.  
  56. $delete = "DELETE FROM SKU_Group_Dim WHERE Group_ID = '$Group_ID'";
  57.  
  58. $stmt = $pdo->prepare($delete);
  59. $result = $stmt->execute();
  60. echo json_encode($result);
  61. if(!$result) {
  62. echo sqlsrv_errors();
  63. }
  64.  
  65. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement