EasyUI Forum
April 19, 2024, 07:28:33 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: $.messager.progress not updated in windows  (Read 6921 times)
Juan Antonio Martínez
Jr. Member
**
Posts: 68



View Profile
« on: August 15, 2015, 04:06:25 AM »

Hi all
I'm using a $.messager.progress to monitorize a php long-script task at server side.
This is done by mean of making calls to server and retrieve progres status stored in $_SESSION variables

Here comes the relevant client side code:

Code:
                   // open messager window
                   $.messager.progress({
                        title: 'Restore',
                        msg: 'Restoring database',
                        interval: 0 // do not perform auto update.
                    });

                    // perform call to long time consuming php server side task ( restore database contents with provided file )
                    $.ajax({
                        type:'POST', // use post to send file
                        url:"/agility/server/adminFunctions.php",
                        dataType:'json',
                        data: {
                            Operation: 'restore',
                            Data: $('#tools-restoreData').val()
                        },
                        contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
                        success: function(data) {
                            if (data.errorMsg){
                                $.messager.show({ width:300, height:150, title: 'Database Restore Error', msg: data.errorMsg });
                            } else {
                                $.messager.alert("Restore Database","Base restore success<br />Please reinit application","info");
                            }
                            $.messager.progress('close');
                        },
                        error: function(XMLHttpRequest,textStatus,errorThrown) {
                            $.messager.alert("DBRestore Error","Error: "+textStatus + " "+ errorThrown,'error' );
                            $.messager.progress('close');
                        }
                    });

                    // function to monitorize database restore progress info
                    function getProgress(){
                        $.ajax({
                            url:"/agility/server/adminFunctions.php",
                            dataType:'json',
                            data: {
                                Operation: 'progress'
                            },
                            success: function(data) {
                                if( data.progress !== "Done" ){
                                    var bar = $.messager.progress('bar');  // get the progressbar object
                                    bar.progressbar('setValue', data.progress);  // set new progress value
                                    setTimeout(getProgress,200); // reload progress status in 200 msecs
                                } else {
                                    $.messager.progress('close');
                                }
                            }
                        });
                    }

                    // start monitoring database restore progress info
                    setTimeout(getProgress,200);

At server side there are "standard" session status handling:
Code:
.....
if ($operation==="progress") {
// retrieve session status and return
session_start();
$sid="0";
if (isset($_SESSION["progress"])) $sid=$_SESSION["progress"];
echo json_encode( array( 'progress' => strval($sid) ) );
return;
}
....

// called several times from long time consuming php process
function setSessionProgressStatus($str) {
session_start(); // if session is already started this call is ignored
$_SESSION["progress"]=$str;
session_write_close(); // flush and unlock session vars to allow another process to access them
}
....


I't works fine.... in Linux and Mac.
When trying  to use it in Windows 7 (either Fireforx or Chrome) only one ajax call is submitted to monitorize progress, Thus only last "Done" report is received

I'm unsure but think that long script blocks server, so progress monitor calls are ignored until main task ends, thus the one and only message received is last one

Is it true, or there are something wrong in my client-side code?

Thanks in advance
Juan Antonio
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!