I'm making a webpage and I need to update a database in a Node.js server when the window is closed.
The code is:
window.close(function(){
event.preventDefault();
var UrlCierra = location.search && location.search.split('=')[1];
var cierro = $.post( '/updatesala/cerrarventana', {url: UrlCierra} );
cierro.done(function(data){
if (data=="Cierra"){
window.close();
}
});
});
I know that the code is wrong, but how can I fix it?