473,508 Members | 2,250 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,javascript
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(getData) in a periodic time?
thanks alot
Jul 19 '09 #1
3 5321
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
1829
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...
0
1801
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...
3
2380
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...
4
1516
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...
0
3282
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 =...
8
2703
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...
5
8866
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...
18
4312
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...
5
1533
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....
0
7127
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...
0
7391
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...
0
5633
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,...
1
5056
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...
0
4713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3204
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1564
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
768
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.