EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Juan Antonio Martínez on August 22, 2015, 04:30:01 PM



Title: window('open'); something.each(); then window('close') doesn't work in chrome
Post by: Juan Antonio Martínez on August 22, 2015, 04:30:01 PM
Hi all.
I want a progress dialog window to be shown while several ajax call are being processed. So I have following code:
Code:
<!-- progress window to show inscription progress -->
<div id="new_inscripcion-progresswindow" class="easyui-window"
data-options="title:'Processing...',width:450,modal:true,collapsable:false,minimizable:false,maximizable:false,closable:false,closed:true">
<p id="new_inscripcion-progresslabel" style="text-align:center">Inscribiendo a:</p>
<div id="new_inscripcion-progressbar" class="easyui-progressbar" style="width:300px;text-align:center;" data-options="value:0"></div>
</div>
....
function insertInscriptions(dg) {
....
        var pwindow=$('#new_inscripcion-progresswindow');
var selectedRows= dg.datagrid('getSelections'); // take selected rows from provided datagrid
var count=1;
var size=selectedRows.length;

pwindow.window('open');
$.each(selectedRows, function(index,row) {
$('#new_inscripcion-progresslabel').text("Inscribiendo a: "+row.Nombre);
$('#new_inscripcion-progressbar').progressbar('setValue',(count*(100/size)).toFixed(2));
$.ajax({
           async: false, // NOTICE async set to false to ensure each() returns after last ajax call completed
           cache: false,
           timeout: 10000, // 10 seconds
   type:'GET',
   url:"/agility/server/database/inscripcionFunctions.php",
   dataType:'json',
   data: {
                               .....
   }
});
count++;
});
pwindow.window('close');
....
}

This code works fine in firefox: window is displayed, and progressbar shows progress on each ajax sync call; and when last ajax call is performed, window is closed
But when running in Google Chrome, window does not appear, ajax calls are performed but no window nor progress shown

What am I doing wrong?
Thanks in advance


Title: Re: window('open'); something.each(); then window('close') doesn't work in chrome
Post by: jarry on August 22, 2015, 06:38:19 PM
Due to the detrimental effects to the end user's experience, the chrome does not allow synchronous request on the main thread. Please prevent from setting async to false when calling $.ajax.


Title: Re: window('open'); something.each(); then window('close') doesn't work in chrome
Post by: Juan Antonio Martínez on August 23, 2015, 01:27:17 AM
OK. I've seen deprecation notice in chrome dev console, but didn't know that modern chrome just ignores 'async:false' directive

I'll rewrite my code.
Thanks