Skip to content

Instantly share code, notes, and snippets.

@unique1984
Last active September 30, 2019 11:08
Show Gist options
  • Save unique1984/611b9a102ddcbe10f337c9fa9e1d4928 to your computer and use it in GitHub Desktop.
Save unique1984/611b9a102ddcbe10f337c9fa9e1d4928 to your computer and use it in GitHub Desktop.
Ajax Window operations
// sayfayı açtığında veya yenilediğinde
$(document).ready(function () {
$.ajax({
type: 'POST',
url: "./open.php",
data: {
adminId: "123456_Yasin",
message: "open"
},
async: false
});
});
// sayfayı kapanmadan hemen önce
$(window).bind("beforeunload", function () {
$.ajax({
type: 'POST',
url: "./offline.php",
data: {
adminId: "123456_Yasin",
message: "offline"
},
async: false
});
});
// başka sekmeye geçtiğinde
$(window).bind("blur", function () {
$.ajax({
type: 'POST',
url: "./away.php",
data: {
adminId: "123456_Yasin",
message: "away"
},
async: false
});
});
// Sekmeye odaklandığında
$(window).bind("focus", function () {
$.ajax({
type: 'POST',
url: "./online.php",
data: {
adminId: "123456_Yasin",
message: "online"
},
async: false
});
});
@unique1984
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment