Guest User

Untitled

a guest
Sep 21st, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. employeeTable.find(".command-edit").on("click", function(event)
  2. {
  3. var eid = $(this).data("row-id");
  4.  
  5. // At this point i can get the alert values o.k.
  6.  
  7. alert("You pressed edit on row: " + $(this).data("row-id"));
  8. alert("You pressed edit on row: "+""+eid);
  9.  
  10. //but here is the issue
  11.  
  12. $.ajax({
  13. url:"fetch_single.php",
  14. method:"POST",
  15. data:{eid:eid},
  16. dataType:"json",
  17. cache: false,
  18.  
  19. success: function(data){
  20. alert('success');
  21. },
  22.  
  23. // its always failing.
  24.  
  25. error: function(){
  26. alert('failure');
  27. }
  28.  
  29. <?php
  30. //fetch_single.php
  31.  
  32. include_once("db_connect.php");
  33.  
  34. if(isset($_POST["eid"]))
  35. {
  36. $output = array();
  37.  
  38. $query = "SELECT * FROM employee WHERE id = '".$_POST["eid "]."'";
  39. $result = mysqli_query($connection, $query);
  40. while($row = mysqli_fetch_array($result))
  41. {
  42. $output["id"] = $row["id"];
  43. $output["employee_name"] = $row["employee_name"];
  44. $output["employee_salary"] = $row["employee_salary"];
  45. $output["employee_age"] = $row["employee_age"];
  46.  
  47. }
  48. echo json_encode($output);
  49. }
  50.  
  51. ?>
Add Comment
Please, Sign In to add comment