N°3786 - Add pause at the end of the page unload async request to follow the guideline used in N°2763

This commit is contained in:
Molkobain
2021-07-16 20:02:04 +02:00
parent 68f3c53faa
commit e15953524a
2 changed files with 19 additions and 1 deletions

View File

@@ -115,10 +115,11 @@ function OnUnload(sTransactionId, sObjClass, iObjKey, sToken)
// IMPORTANT: the ajax request MUST BE synchronous to be executed in this context
$.ajax({
url: GetAbsoluteUrlAppRoot()+'pages/ajax.render.php',
async: false,
async: true,
method: 'POST',
data: {operation: 'on_form_cancel', transaction_id: sTransactionId, obj_class: sObjClass, obj_key: iObjKey, token: sToken }
});
CombodoGlobalToolbox.Pause(1000);
}
}

View File

@@ -725,6 +725,23 @@ const CombodoGlobalToolbox = {
sOutput = sOutput.replace(/<script/g, '&lt;script WARNING: scripts are not allowed in tooltips');
return sOutput;
},
/**
* Pause the JS activity for iDuration milliseconds
*
* @see N°2763 for the original code idea
* @return {void}
* @param iDuration {integer} Duration in milliseconds
* @constructor
*/
Pause: function (iDuration) {
const oDate = new Date();
let oCurrentDate = null;
do {
oCurrentDate = new Date();
}
while ((oCurrentDate - oDate) < iDuration);
}
};