EasyUI Forum
April 25, 2024, 03:49:26 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Dynamic Progressbar With Ajax  (Read 16861 times)
anugrast
Jr. Member
**
Posts: 52


View Profile Email
« on: May 01, 2015, 06:55:50 PM »

I want to create dynamic progressbar to show real progress when I process some data with ajax... Can anyone help me... Please....
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: May 02, 2015, 05:37:11 AM »

When you retrieve the progress value, you can call 'setValue' method to display the real progress.
Code:
var value = ...
$('#pb').progressbar('setValue', value);
Logged
anugrast
Jr. Member
**
Posts: 52


View Profile Email
« Reply #2 on: May 02, 2015, 08:24:33 PM »

This is my code...

HTML & JS:

Code:
    <div style="margin:20px 0;">
        <a href="#" class="easyui-linkbutton" onclick="start()">Start</a>
    </div>
    <div id="pb" class="easyui-progressbar" style="width:400px;"></div>

    <script>
function start(){
$.ajax({
async:true,
type:"POST",
url: '_modul/mod_bengkel/aksi_bengkel.php',
success: function(result) {
var hasil=parseInt(result)+0;
var value = $('#pb').progressbar('getValue');
if(value < 100) {
value += hasil * 10;
$('#pb').progressbar('setValue', value);
}
}
});
};
    </script>

And this is my PHP file

Code:
for ($x = 1; $x <= 100; $x++) {
if($x>1) sleep(2);
echo $x;
}

When I click start, it's nothing happen...

I need your advise how to fix it....
Please....
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: May 03, 2015, 05:43:14 PM »

Your PHP code takes a long time(99*2 seconds) to response to the browser, please correct it.
Code:
for ($x = 1; $x <= 100; $x++) {
if($x>1) sleep(2);
echo $x;
exit(0);
}
Logged
anugrast
Jr. Member
**
Posts: 52


View Profile Email
« Reply #4 on: May 03, 2015, 07:01:09 PM »

Thanks for your respond...

Why in my progressbar only show 1 step (I mean only show 1% and stack...), there is something else that I should put on my script...
Logged
anugrast
Jr. Member
**
Posts: 52


View Profile Email
« Reply #5 on: May 05, 2015, 08:46:50 PM »

Anyone help... please...
Logged
lloyd
Newbie
*
Posts: 29


View Profile Email
« Reply #6 on: January 28, 2016, 05:21:31 AM »

You should create an event message handler.

See: http://www.w3schools.com/HTML/html5_serversentevents.asp example.

I have used it in my code when I export data to a csv file. Smiley
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!