title: Count the time spent by visitor on my website using AJAX
body: <p>Can someone help me with my script Ajax? I want to count the time spent by a visitor on my website and send the variable to a PHP page :</p>
  
  <pre><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  var start;
  
  $(document).ready(function() {
  start = Date.getTime();
  
  $(window).unload(function() {
    end = Date.getTime();
    $.ajax({
      url: 'timer.php',
      type:'POST',
      async: false,
      data: {
              'timeSpent': end - start,
              x:'hello'
            }
    })
  });
  }
  </code></pre>
  
  <p>
     and in timer.php i put  :                                                 </p>