Guest User

input ajax

a guest
Dec 8th, 2019
182
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <div class="body">
  2. <form method="post" class="form-simpan">
  3. <div class="form-group">
  4. <div class="form-line">
  5. <label for="nim">NIM</label>
  6. <input type="text" class="nim form-control" name="nim" id="nim" placeholder="Ex : 1610307057004" autofocus required>
  7. </div>
  8. </div>
  9. <div class="form-group">
  10. <div class="form-line">
  11. <label for="nama">Nama</label>
  12. <input type="text" class="form-control" name="nama" id="nama" placeholder="Ex : Budi Setiawan" autofocus required>
  13. </div>
  14. </div>
  15. <div class="form-group">
  16. <div class="form-line">
  17. <label for="email">Email</label>
  18. <input type="text" class="form-control" name="email" id="email" placeholder="Ex : Bangunpsb@gmail.com" autofocus required>
  19. </div>
  20. </div>
  21. <div class="form-group">
  22. <div class="form-line">
  23. <label for="password">Password</label>
  24. <input type="password" class="form-control" name="password" id="password" placeholder="Ex : ##############" autofocus required>
  25. </div>
  26. </div>
  27. <div class="form-group">
  28. <label for="level">Status Akses</label>
  29. <select name="level" id="level" class="form-control show-tick" data-live-search="true" required>
  30. <option value="" disabled selected>Pilih Status</option>
  31. <option value="admin">ADMIN</option>
  32. <option value="karyawan">KARYAWAN</option>
  33. </select>
  34. </div>
  35. <div class="form-group">
  36. <div class="form-line">
  37. <label for="no_hp">No Hp</label>
  38. <input type="text" class="form-control" name="no_hp" id="no_hp" placeholder="Ex : 081232323" autofocus aria-required="">
  39. </div>
  40. </div>
  41. <div class="form-group">
  42. <button class="simpan btn btn-success">Simpan</button>
  43. </div>
  44. </form>
  45. </div>
  46.  
  47. </div>
  48. </div>
  49. </div>
  50. <!-- #END# Basic Examples -->
  51. <!-- #END# Widgets -->
  52. </div>
  53. </section>
  54.  
  55.  
  56. <script type="text/javascript">
  57. $(document).ready(function() {
  58. $(".simpan").click(function() {
  59. var data = $(".form-simpan").serialize("value");
  60. $.ajax({
  61. type: 'post',
  62. url: 'admin/simpan.php',
  63. data: {
  64. "simpan": data
  65. },
  66. success: function(s) {
  67. alert(data);
  68. if (s = true) {
  69. window.location.reload();
  70. }
  71. }
  72. });
  73. });
  74. });
  75. </script>
RAW Paste Data