Advertisement
Lucky101

Script.js

Jun 28th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.95 KB | None | 0 0
  1. $(".btn-submit").click(function() {
  2.         let url = $(".form").attr("action");
  3.         let data = $(".form").serialize();
  4.         $("#loader").show();
  5.         $.ajax({
  6.             type: "POST",
  7.             url: url,
  8.             data: data,
  9.             dataType: "json",
  10.             success: function(response) {
  11.                 if (response.status == "failed") {
  12.                     $.each(response.message, function(index, value) {
  13.                         if (value) {
  14.                             M.toast({
  15.                                 html: value,
  16.                                 classes: "white-text red lighten-1 z-depth-3"
  17.                             });
  18.                         }
  19.                     });
  20.                     $("input[name=CSRFTOKENFQRPLN]").val(response.token);
  21.                     $("#loader").hide();
  22.                 } else if (response.status == "success") {
  23.                     M.toast({
  24.                         html: response.message,
  25.                         classes: "white-text green lighten-1 z-depth-3"
  26.                     });
  27.                     $("input[name=CSRFTOKENFQRPLN]").val(response.token);
  28.                     $("#itemname").val("");
  29.                     $("#itemammount").val("");
  30.                     $("#datatable").load("http://localhost/latujikomci/admin/load_table");
  31.                     $("#loader").hide();
  32.                 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement