Created
November 27, 2018 16:49
-
-
Save oampo/61c1dbb3010f593fe35ba96b42d63cb3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
</head> | |
<body> | |
<script src="https://code.jquery.com/jquery-3.3.1.js"></script> | |
<script> | |
function onUnload() { | |
$.ajax({ | |
type: "POST", | |
url: "http://localhost:8080/unload", | |
async: false | |
}); | |
} | |
window.onbeforeunload = onUnload; | |
</script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
app.post('/unload', (req, res) => { | |
console.log('Unload'); | |
res.json('Wohoo'); | |
}); | |
app.listen(8080); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment