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;
}
});
});
});
See Question&Answers more detail:os