I'm trying to debug an issue with some PHP/MySQL/jQuery code that handles pessimistic locking. It uses two fields: locking_user_id and locking_date_time. The locking is determined by an AJAX action to PHP/MySQL. The jQuery code below shows the typical update for the locking which occurs every 15 seconds. There's also a save action every 10 minutes.
My question is, what happens to the jQuery/Locking Update when someone's computer goes into "sleep mode" or is "locked" for a few hours? Will the AJAX call continue? I assume the setTimeout() no longer runs? One person is knowingly allowing edit views to remain open for hours at a time. I'm fairly certain this is causing the issue were seeing. I'm building in additional PHP validation checks on update, today.
Does anyone have any suggestions to make the Edit View "timeout" based on inactivity?
<script>
// Automatically Save Every 10 Minutes
setInterval(submit_crudForm, 600000); // (1000 * 60 * 10 = 600000)
function submit_crudForm() {
$('#crudForm').submit();
}
// Set Update Locking
function updateLockingCount () {
$.getJSON('https://wwww.thedomain.com/catalog/ajax_update_locking/1004', function(data) {
//console.log(data);
setTimeout(updateLockingCount, 15*1000);
});
}
$(function () {
updateLockingCount();
});
Related Post: PHP/MySQL/jQuery Pessimistic Locking of Record