fork download
  1. $(function() {
  2. //----- OPEN
  3. $('[data-modal-open]').on('click', function(e) {
  4. $('#insert_form')[0].reset();
  5. var targeted_modal_class = jQuery(this).attr('data-modal-open');
  6.  
  7. $('[data-modal="' + targeted_modal_class + '"]').fadeIn(350);
  8. e.preventDefault();
  9. });
  10.  
  11. //----- CLOSE
  12. $('[data-modal-close]').on('click', function(e) {
  13. var targeted_modal_class = jQuery(this).attr('data-modal-close');
  14. $('[data-modal="' + targeted_modal_class + '"]').fadeOut(350);
  15.  
  16. e.preventDefault();
  17. });
  18. });
  19. $(document).ready(function(){
  20. $('#add').click(function(){
  21. $('#insert').val("Insert");
  22. $('#insert_form')[0].reset();
  23. });
  24. $(document).on('click', '.edit_data', function(){
  25. var employee_id = $(this).attr("id");
  26. $.ajax({
  27. url:"fetch.php",
  28. method:"POST",
  29. data:{employee_id:employee_id},
  30. dataType:"json",
  31. success:function(data){
  32. $('#name').val(data.name);
  33. $('#address').val(data.address);
  34. $('#gender').val(data.gender);
  35. $('#designation').val(data.designation);
  36. $('#age').val(data.age);
  37. $('#employee_id').val(data.id);
  38. $('#insert').val("Update");
  39. $('[data-modal="add_data_modal"]').fadeIn(350);
  40.  
  41.  
  42. }
  43. });
  44. });
  45. $('#insert_form').on("submit", function(event){
  46. event.preventDefault();
  47. if($('#name').val() == "")
  48. {
  49. alert("Name is required");
  50. }
  51. else if($('#address').val() == '')
  52. {
  53. alert("Address is required");
  54. }
  55. else if($('#designation').val() == '')
  56. {
  57. alert("Designation is required");
  58. }
  59. else if($('#age').val() == '')
  60. {
  61. alert("Age is required");
  62. }
  63. else
  64. {
  65. $.ajax({
  66. url:"insert.php",
  67. method:"POST",
  68. data:$('#insert_form').serialize(),
  69. beforeSend:function(){
  70. $('#insert').val("Inserting");
  71. },
  72. success:function(data){
  73. $('#insert_form')[0].reset();
  74. $('[data-modal="add_data_Modal"]').fadeOut(350);
  75.  
  76. $('#add_data_Modal').modal('hide');
  77. $('#employee_table').html(data);
  78. }
  79. });
  80. }
  81. });
  82. $(document).on('click', '.view_data', function(){
  83. var employee_id = $(this).attr("id");
  84. if(employee_id != '')
  85. {
  86. $.ajax({
  87. url:"select.php",
  88. method:"POST",
  89. data:{employee_id:employee_id},
  90. success:function(data){
  91. $('#employee_detail').html(data);
  92. $('[data-modal="empdetail"]').fadeIn(350);
  93.  
  94. }
  95. });
  96. }
  97. });
  98. });
Runtime error #stdin #stdout #stderr 0.43s 42140KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
js: uncaught JavaScript runtime exception: ReferenceError: "$" is not defined.