Passing Javascript variable in my module file

by Rakesh Verma   Last Updated July 27, 2015 14:03 PM

How can I pass a JS variable to my module file using ajax in drupal?

var start;
start = new Date().getMinutes();
   window.onbeforeunload = function() {
     var end1 = new Date();
     var end = end1.getMinutes();
     var timespan = end - start;

This is my JS file and I want to use this "timespan" variable in my PHP file but unable to figure out how.

Tags : javascript

Related Questions

Use drupal.settings variables on javascript

Updated March 27, 2015 14:18 PM

Calling a contact form in a certain page

Updated August 23, 2015 17:03 PM

Remove jquery script

Updated April 20, 2015 21:03 PM