Can any one help me in recording time spent by the user in a particular page? I also need to send that data to a PHP file where it will need to be stored in a database.
This is what I have so far:
var time = 1;
function timeHere() {
time = time + 1;
finalTime = time / 10;
}
function sayTime() {
finalTime = time / 10;
sendTimeSpent(finalTime);
}
function sendTimeSpent(finalTime) {
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET", "/Test/Timer/StoreTime.php?time=" + finalTime, true);
xmlhttp.send();
}
Here i dont need any response from the server…
I just need to send the data to the server…
I would use jQuery, but still I’m not fond on the idea.