This is script

<script>
var time=1;

function timeHere() {
  time = time + 1;
  finalTime = time / 10;

}

function sayTime() {
  finalTime = time / 10;
  
}
</script>

<body onload='window.setInterval("timeHere()", 100)' onunload="sayTime()">

</body>

I want to get the time i.e. value of finalTime in ajax varable.

Not using cookie, becoz it gives value on same page but after reloading page am using this to javaScript to php

How i get this without reloading or refreshing page...
so question is How to save value of variable in javaScript to ajax variable??

means save value of finalTime in ajax variable
How to do this??

There is no such thing as AJAX variable. In case if you want to persist a Javascript variables' value to a persistent store by making an async request to the server, you can just append the value in consideration to the query string like:

http://your.server/?value=yourValue

which would be read at the server (using a server side environment of your choice) and then persisted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.