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

  • SEARCH
  • Home
  • 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 7700799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:49:52+00:00 2026-05-31T22:49:52+00:00

I made a counter that counts from one to infinity and if I refresh

  • 0

I made a counter that counts from one to infinity and if I refresh the page it doesn’t stop.
However I have used ajax to update some datas in the database and this isn’t working well …
I think the problem is thet the ajax file dosn’t run

HTML :

<html>
<head>
<?php include "config.php"; ?>
<script type="text/javascript">
function createXMLHttpRequest(){
    var ua;
    if(window.XMLHttpRequest) {
        try {
            ua = new XMLHttpRequest();
        }catch(e) {
            ua = false;
        }
    }else if(window.ActiveXObject) {
        try{
            ua = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(e) {
            ua = false;
        }}
return ua;}
var some = createXMLHttpRequest(c);
function some1(){
    some.open('GET', 'Untitled_4.php?value='+c);
    some.onreadystatechange = hand;
}
function hand() {
 if(some.readyState == 4) 
 {      
       some.send(null);
 }
}
var c=
<?php 

    $c= mysql_fetch_array( mysql_query("SELECT * FROM  `clock` WHERE `id`=1"));
    $l=time()-$c['time'];
    $a=$l/1;
    $a=floor($a);
    $a=$a+$c['value'];
    echo $a;

?>;
var t;
var timer_is_on=0;

function timedCount()
{
document.getElementById('txt').innerHTML=c;
c=c+1;
t=setTimeout("timedCount()",1000);
}

function doTimer()
{
if (!timer_is_on)
  {
  timer_is_on=1;
  timedCount();
  }
}
</script>
</head>

<body onunload="some1(c)" onload="doTimer()">
<form>
<div  id="txt" ></div>
</form>
</body>
</html>

AJAX File :

<?php
include "config.php";
$value=$_GET['value'];
mysql_query("UPDATE `clock` SET `time`=".time().",`value`= $value  WHERE `id` = 1 ");
echo "1";
?>
  • 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-05-31T22:49:53+00:00Added an answer on May 31, 2026 at 10:49 pm

    The readystate won’t update unless you send the XMLHttpRequest.
    The following version of some1 should fix your problem:

    function some1(){
        some.open('GET', 'Untitled_4.php?value='+c);
        some.send(null);
    }
    

    You don’t really need the onreadystatechanged handler because you send the request when the page unloads and there won’t be enough time to handle a change of the XMLHttpRequest’s state I guess.

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

Sidebar

Related Questions

We have one ajax request that refresh some counter in our layout page. The
I have implemented a page hit counter which counts the number of page views
I have a peice of code that counts from 0 to a specified number
I made a class that derives from Component: public class MyComponent: System.ComponentModel.Component { }
I made a code that translate strings to match each word from the array
I've made a loop with i as it's counter variable. Inside that loop I'm
So I have a gauge that I've made that will be animating in either
I made an app that is just a simple counter that will keep track
I have a UIView that contains a drawing that I've made using CALayers added
I have a query that grabs information from four different tables, and joins them

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.