Login   Register  
PHP Classes
elePHPant
Icontem

File: siteaccess/siteaccess.js

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of MarPlo  >  Web Site Traffic and Pages Access  >  siteaccess/siteaccess.js  >  Download  
File: siteaccess/siteaccess.js
Role: Auxiliary data
Content type: text/plain
Description: Ajax function
Class: Web Site Traffic and Pages Access
Record visits of real users to Web site pages
Author: By
Last change:
Date: 2013-08-16 00:03
Size: 846 bytes
 

Contents

Class file image Download
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);