Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7845051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:05:54+00:00 2026-06-02T17:05:54+00:00

I am trying to put this into ajax so everytime a person clicks a

  • 0

I am trying to put this into ajax so everytime a person clicks a button in jquery, it creates a php session. Is it possible just using this?

var milisec=00;
var seconds=60; 
function display(){ 
    if (milisec<=0){ 
       milisec=9 
       seconds-=1 
    } 
    if (seconds<=-1){ 
       milisec=0 
       seconds+=1
    } 
    else {
       milisec-=1 
       document.getElementById('counter').innerHTML= seconds+":"+"0"+milisec+"s";
       setTimeout(display,100) 
    }
    if (seconds < 10) {
       document.getElementById('counter').innerHTML=  "0"+seconds+":"+"0"+milisec+"s";
    }
} 
display()

I need to post the time it took for them to get to the next page using Php sessions, using ajax.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:05:58+00:00Added an answer on June 2, 2026 at 5:05 pm
      var seconds = 60;
      var milisec = 0;
      var stop_counter = false;    
    
      function display(){ 
    
        if(milisec == 0)      
          seconds = seconds - 1;
    
        milisec = milisec - 1;
    
        if(milisec == -1)
          milisec = 10;        
    
        $('#counter').html((seconds < 10 ? "0" : "") + seconds + ":0" +milisec+ "s");        
    
        if( (seconds == 0 && milisec == 0 && stop_counter == true) == false )
          setTimeout(function(){ display(); }, 100);
    
      }     
    
    
      $(document).ready(function(){
    
        display();
    
        $('#button').click(function(){
    
          $.post('myphpfile.php', {time : $('#counter').text()}, function(data){
    
            alert('Data from myphpfile.php: ' + data);
            stop_counter = true; //stop counter now
    
          });
    
        });
    
      });
    

    myphpfile.php

    echo 'you clicked button when counter was ' . $_POST['time'];
    //you can do any php stuff here
    

    this code should do what you want but I did not test it.

    function $.post() from jQuery library will pass your data to php script and also can retrieve some data which you can display on your site or something.

    btw, one second has 1000 miliseconds, not 100

    sorry for my english

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been looking into this for a while now. I'm trying to put a
I'm trying to put tag into JQuery-ui dialog widget. Due to some other problems
I want to put this method into background worker class, i am trying but
I'm trying to click a link & put that text into a jquery dialog
HI all, I am trying to figure out how to put this into words
I'm trying to put a list of dictionary words from an AJAX call into
I'm trying to put this data type in a Haskell Set, but I don't
I'm looking for some assistance with some code. I'm trying to put this to
Edit: I put this snippet of code in jsbin: http://jsbin.com/eneru I am trying to
I am trying to put together a GWT webapp following this GWT MVP tutorial

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.