473,785 Members | 2,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

calling function in a periodic time

oranoos3000
107 New Member
hi
i want to get time of server with ajax,php,javasc ript
i use under scritp and with method onload i get time on server and show on the page
so i want in a period time the same function is run but
result is fixed and error is given

my script is
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5. <title>Untitled Document</title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  7.     <script language = "javascript">
  8.       var XMLHttpRequestObject = false; 
  9.  
  10.       if (window.XMLHttpRequest)
  11.       {
  12.         XMLHttpRequestObject = new XMLHttpRequest();
  13.       }
  14.       else if (window.ActiveXObject)
  15.       {
  16.         XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
  17.       }
  18.  
  19.       function getData(dataSource, divID) 
  20.       { 
  21.             if(XMLHttpRequestObject)
  22.             {
  23.                   var obj = document.getElementById(divID);
  24.                   var rand = Math.floor(Math.random()*59884555445);
  25.                   var ds= dataSource+'?rand='+rand;
  26.                   XMLHttpRequestObject.open("GET", ds); 
  27.  
  28.                   XMLHttpRequestObject.onreadystatechange = function() 
  29.                   { 
  30.                     if (XMLHttpRequestObject.readyState == 4 && (XMLHttpRequestObject.status == 200 || XMLHttpRequestObject.status == 0))
  31.                     { 
  32.                         obj.innerHTML = XMLHttpRequestObject.responseText; 
  33.                     } 
  34.                   } 
  35.  
  36.  
  37.                   XMLHttpRequestObject.send(null); 
  38.             }
  39.             window.setTimeout("getData("+dataSource+","+ divID+")",1000);
  40.       }
  41.     </script>
  42. </head>
  43.  
  44. <body onLoad="getData('time.php','idtarget')">
  45. <div id="idtarget"></div>
  46. </body>
  47. </html>
and time.php is
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. echo date("H:i:s");
  3. ?>
how can i repeat calling function(getDat a) in a periodic time?
thanks alot
Jul 19 '09 #1
3 5332
acoder
16,027 Recognized Expert Moderator MVP
Use setInterval to call a function repeatedly.
Jul 20 '09 #2
nisi
1 New Member
hi its much time now so if you have got the answer please put it here
Sep 12 '13 #3
gits
5,390 Recognized Expert Moderator Expert
the answer is above your post already. use the setInterval method for this.
Sep 12 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1844
by: Hans Forbrich | last post by:
Section 1. Ballot: ------------------- 1.YES NO: I agree that there should be a periodic post describing the newsgroup charter and providing a FAQ on newsgroup usage. 2.MONTHLY BI-WEEKLY WEEKLY: The post should be transmitted with this frequency.
0
1827
by: Hans Forbrich | last post by:
Section 1. Ballot: ------------------- 1.YES NO: I agree that there should be a periodic post describing the newsgroup charter and providing a FAQ on newsgroup usage. 2.MONTHLY BI-WEEKLY WEEKLY: The post should be transmitted with this frequency.
3
2393
by: Ken | last post by:
hello, I would to know if it is possible to call an object in a function within a class. Meaning , In a class, A function X calling onto a function Y, and function Y we want one of the two calculation ( eg seconds , out of seconds and minutes) thanks , Ken
4
1526
by: Richard Townsend | last post by:
I've been experimenting putting a reference to a function into a Queue object and was wondering what actually gets put in the Queue - is it the function's code object? If I read from the Queue in a different module, it appears that I don't need to import the module that defines the function - or any module that it uses - is this generally true, or are there some conditions to be aware of? The scenario I'm working on has child threads...
0
3291
by: Jeffrey B. Holtz | last post by:
Has anyone used the multimedia timere timeSetEvent in C#? I'm trying to use it to get a 1ms accurate timer. All the other implementations are far to inaccurate in their resolution. 1ms Timer = 0ms.....60ms. I'm already timing the callbacks using the Win32API QueryPerformanceCounter/Frequency. The code I have is actually performing the callback and it looks like it is close to 1ms but I now need to get my object passed to this static...
8
2738
by: Stephen Rice | last post by:
Hi, I have a periodic problem which I am having a real time trying to sort. Background: An MDI VB app with a DB on SQL 2000. I have wrapped all the DB access into an object which spawns a thread to access the database and then displays a modal dialog which allows the user to cancel the task, if it is taking longer than they want, and shows them a display of how long the query has been running so far.
5
8912
by: nishantxl | last post by:
Hi there, I am looking to design a project using C++ The main objective of the project is to display details of periodic table elements such as periodic element name, properties(such as atomic number and atomic mass) for each periodic number entered by user. I am thinking to input all the data regarding each periodic element number in form of class. Please give your opinion on the correct design method for the same.
18
4359
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I can use dlopen/whatever to convert the function name into a pointer to that function, but actually calling it, with the right number of parameters, isn't easy. As far as I can see, there are only two solutions: 1) This one is portable. If...
5
1542
oranoos3000
by: oranoos3000 | last post by:
hi I want to repeat executing a seri of the code in page in interval periodic time without use from infinite loop and i prefer that page is not refreshed only a seri of the code is execute. this codes execute repeatedly How can i carry out this work? thanks a lot
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10329
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10152
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8974
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7500
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.