I am trying to create a shopping cart with reservation time, the remaining time is calculated by PHP. Since the user enters the requested page, the time is executed with the integer of seconds, which comes from php (session). If 3 minutes is left, then Javascript starts a confirmation box and the user asks if he wants to reset the timer with his car.
While confirmation box is shown, execution timer is stopped How can I change my code so that the timer can stop the box without confirmation?
// Start the counter in the document. Rd-block / remainingSeconds ($ _ session ['timer']) stays in seconds (as int) CountDownTimer ('& lt ;? php Remaining dumb balance ($ _ session [' timer ']) ?? Gt; ',' Reserved Time ');
And here's the Mozilla Timer function:
// These functions are located in external .js-file // found on stack overflow and it Edited CountDownTimer for my needs function (dt, id) {if (id == "kill") {clearInterval (timer); } And {var _second = 1, _minute = _second * 60, _hour = _minute * 60; ShowRemaining function () {var time = DT--, minutes, seconds; If (DT == 180) {var extension = Confirm ("Reset timer?"); If (extension) {resetCounter (); }} If (DT <0) {clear interval (timer); Document.getElementById (ID). WinnerHTML = '00: 00 '; Warning ("no time left."); // - Redirects for removing readability - returns; } If (time> 59) {minutes = math.flur ((time% _hour) / _minute); Seconds = monastery Floor ((%% minutes) / _second); } And {minute = "0"; Secs = time; } (Minutes & lt; 10) {minutes = "0" + minute} if (seconds & lt; 10) {seconds = "0" + seconds} document .getElementById (ID) WinnerHTML = minutes + ":" + sec; } Timer = Set Interval (Showmanning, 1000); }} Function resetCounter () {request = $ .ajax ({url: "php / ajax.php? F = 3"}); RequestDone (function (response, textStatus, jqxhr) {try data entry = $ .parseJSON (Reaction); CountDownTimer ('0', 'kill'); // Reset old counterdown timer (data.time, 'Reserved Time' ); // Start a new; hold (e) {warning ("error error message"); return false;}}); Request.fail (function (jqxhr, textstatus, error trouver) {warning ("error");}); }
As the timer is stopped, it will create a time that is different from that session. So the car might expire - but the user will not note it and lose its reserve items.
Edit: Or is there a better / secure method to integrate the shopping cart timer with the user's output so that there is no time difference?
Comments
Post a Comment