progressOn/Off before and after an AJAX request.

Here’s my piece of code:

function onToolBarClick(id) { if (id == "htm") { if (dhxTree.getAllChecked().length) { // dhxLayout.progressOn(); var rand = Math.floor(Math.random() * 9999); var loader = dhtmlxAjax.getSync("report.asp?data=" + dhxCalendar.getFormatedDate("%d/%m/%Y", dhxCalendar.getDate()) + "&linea=" + dhxTree.getAllChecked() + "&rand=" + rand); if (loader.xmlDoc.responseText != "") { if (loader.xmlDoc.responseText == "*") { document.location.href = "../login.asp"; } else { dhxLayout.cells("b").attachURL("report.asp?data=" + dhxCalendar.getFormatedDate("%d/%m/%Y", dhxCalendar.getDate()) + "&linea=" + dhxTree.getAllChecked() + "&rand=" + rand); } } // dhxLayout.progressOff(); } else { alert("Select at least one value."); } } }

Since the AJAX object doesn’t support events how can I use the layout progress indicator to let the user feel that something is working server side and hide it when everything is done?

Thanx,
Alessandro.

You use synchronous loading (getSync method) therefore you may call

dhxLayout.progressOn();
var loader = dhtmlxAjax.getSync(…);
dhxLayout.progressOff();

In case of asynchronous loading:

dhxLayout.progressOn();
dhtmlxAjax.get(url,function(loader){
dhxLayout.progressOff();
});

Hi Alexandra,

thank you for answering me :slight_smile:

Yes I use sync calls but as u can see from my code snippet, the progressOn() and progressOff() functions are included (with remarks) before and after the request. It doesn’t work, nothing comes up. I also tried to set up a long delay on server side script to ensure it was not a timing problem.

I’ll give it a try with async calls and I’ll let you know.

Alessandro.

Hi

Any update on that? Because this doesnt work for me either.
When I use this simple function progress works
function submit() {
attrManagementLayout.progressOn();
alert(tabbar.getActiveTab() == ‘relationship’);
attrManagementLayout.progressOff();
return true;
}

When I put postSync instead of alert progress bar is not showing
function submit() {
attrManagementLayout.progressOn();
var loader = dhtmlxAjax.postSync(ajaxURL, params);
attrManagementLayout.progressOff();
return true;
}

Thanks
Paul

Hi,

When I put postSync instead of alert progress bar is not showing

Probably the response is received too fast to see the progress bar.