Advertisement
virbo

proses sync dengan progres bar

Jul 9th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.19 KB | None | 0 0
  1. =========== FILE JS==========
  2. $(".btn-push").click(function(){
  3.     sync();
  4. });
  5.  
  6. function sync() {
  7.     $.ajax({
  8.         type: "POST",
  9.         url: urlSync,
  10.         beforeSend: function(){
  11.             .................
  12.         },
  13.         success: function(temp) {
  14.             temps = $.parseJSON(temp);
  15.             triger(temps.status);       //buat men-triger proses sync
  16.             bar(temps.proses,temps.persen,temps.jml,temps.total);
  17.             ............
  18.         },
  19.         error: function () {
  20.             ................
  21.         },
  22.     });
  23. }
  24.  
  25. function triger(status){
  26.     if(status) {
  27.         sync();
  28.         return;
  29.     }
  30. }
  31.  
  32. function bar(proses,persen,jml,total) {
  33.     $(".progress-text").html("Proses "+proses);
  34.     $(".progress-bar").css("width",persen+"%");
  35.     $(".progress-number").html(persen+"%");
  36.     $("#progress-result").html("Result: ("+jml+"/"+total+")");
  37. }
  38.  
  39. =================controller
  40. output format json
  41.  
  42. .........
  43. echo Json::encode([
  44.     'persen' => $persen,
  45.         'pesan' => $pesan,
  46.         'proses' => $proses,
  47.         'status' => $status,
  48.         'hasil' => $hasil,
  49.         'jml' => number_format($count_sync-1),
  50.         'total' => number_format($total),
  51. ]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement