Use data generated at the end of a Javascript function in PHP -
i have made site loads info file (a time value), starts (javascript) timer. utilize php add together time recorded on loaded time, have incremental timer carries on lastly time visited. saving of new time value done javascript function feeding php (i assume needs ajax, , haven't figured out how work), or going new php page saving instructions there, in case how carry on info javascript timer? there other methods this? in advance.
the easiest way send info server everytime timer ticks , retrieve later. how using jquery:
sending data:
$.post("time.php", { time:"<time here>" });
getting data
$.get("time.php", function(data) { //start timer here (data time) });
and php code (time.php):
<?php session_start(); //start session if($_post['time'] $_session['time'] = $_post['time']; //if time sent, save session echo $_session['time']; //output saved time ?>
javascript php ajax asynchronous save
No comments:
Post a Comment