This code stores mouse movement coordinates in array and it should post it onbeforeunload. But it doesn’t post. If I change
name: moves
to
name: “blabla”
it works. Means that the problem is on the “moves” variable. How can I make it working ?
$(document).ready(function(){
var moves = [];
$("html").mousemove(function(e){
moves.push(e.pageX + "x" + e.pageY)
});
window.onbeforeunload = function() {
$.ajax({
type: "POST",
url: "mailyaz.php",
data: {
name: moves;
}
});
});
});
You can try this.
It’s a little example that I develop some months ago.
In this case the coordinates are stored in a Text File, but you can replace this with an INSERT into a DataBase.
On the client Side put this:
Now you need a Page in the server side called server.php which contains