var nrsecacc = 5; // number of secconds till ajax function is called to send data to php
var url = window.location;
var title = document.title;
// AJAX function
function ajaxPgAcc() {
if(nrsecacc > 0) {
nrsecacc = -1;
var mypostrequest = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); // create the XMLHttpRequest object
parameters = 'url='+ encodeURIComponent(url.pathname + url.search) +'&title='+ encodeURIComponent(title) +'&isajax=1'; // data to send to php
// Sends data
mypostrequest.open("POST", 'siteaccess.php', true);
mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
mypostrequest.send(parameters);
}
}
// calls ajaxPgAcc() after "nrsecacc" secconds
setTimeout(ajaxPgAcc, nrsecacc * 1000); |