When a user edits a record in my application I track that they have it 'locked' to prevent another user from editing it until the first user closed the window (or saves).
I'm trying to send the request back to the server to unlock the record but it's not working in Firefox. The onbeforeunload event is called in script but it's not sending back the request to the server. Any ideas?
<body>
<script>
window.onbeforeunload = function (e) {
doUnlock();
}
function doUnlock() {
if (navigator.appName == 'Microsoft Internet Explorer') {
// works in IE (with an IFRAME)
utilFrame.location.href = "/unlock.do?recordId=" + recordId;
} else if (navigator.appName == 'Netscape') {
// None of this works....
//window.location.href = "/unlock.do?recordId=" + recordId;
var req = newXMLHttpRequest();
req.open("GET", "/unlock.do?recordId=" + recordId, true);
req.send();
} else {
// Works for chrome
window.open("/unlock.do?recordId=" + recordId);
}
}
</script>