Advertisement
Guest User

js.php

a guest
Dec 15th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. $js2 = <<<JS
  2. $('body').on('beforeSubmit', 'form#dynamic-form', function () {
  3.   // submit form
  4.   console.log('starting ajax request');
  5.  
  6. $.ajax({
  7.       xhr: function() {
  8.           var xhr = new window.XMLHttpRequest();
  9.             xhr.addEventListener('progress', function(e) {
  10.                 if (e.lengthComputable) {
  11.                    $('.progress-bar').css('width', (100 * e.loaded / e.total) + '%').attr( "aria-valuenow", (100 * e.loaded / e.total));
  12.                 }
  13.             });
  14.             return xhr;
  15.       },
  16.       url: form.attr('action'),
  17.       type: 'post',
  18.       data: {id : $('#dynamicmodel-nomor_coil').val()}, // nomor coil digunakan sebagai ID
  19.       dataType : 'json',
  20.       success: function (response, status, xhr) {
  21.  
  22.  
  23.       },
  24.       complete: function(response, status, xhr){
  25.            $('.progress-bar').css('width','0%').attr( "aria-valuenow", "0");
  26.            return xhr;
  27.       }
  28.  }).done(function() {
  29.     jQuery('#dynamicmodel-nomor_coil').prop('disabled', false);
  30. });
  31.  
  32. return false;
  33. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement