Advertisement
Bedhoel

cso_2

Feb 3rd, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $("#f1").on("submit", function (event) {
  2.     event.preventDefault();
  3.     do_proses('f1','index/login','home');
  4. });
  5.  
  6. function do_proses(form_id,act_controller,after_controller){
  7.     $.ajax({
  8.         url: act_controller,
  9.         type: 'POST',
  10.         data: new FormData($('#'+form_id)[0]),  // Form ID
  11.         processData: false,
  12.         contentType: false,
  13.         success: function(data) {
  14.             var data_trim = $.trim(data);
  15.             if(data_trim=="OK"){
  16.                 swal({
  17.                     title: 'Success',
  18.                     type: 'success',
  19.                     showCancelButton: false,
  20.                     showLoaderOnConfirm: false,
  21.                   }).then(function() {
  22.                          if(after_controller!=''){
  23.                             window.location = after_controller;
  24.                          }
  25.                         else {
  26.                             location.reload();
  27.                         }
  28.                  });
  29.             }
  30.             else if(data_trim=="NOK"){
  31.                   swal({
  32.                     title: 'Error',
  33.                     text: "Username / Password Salah",
  34.                     type: 'error',
  35.                     showCancelButton: false,
  36.                     showLoaderOnConfirm: false,
  37.                   });
  38.             }
  39.         }
  40.     });
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement