473,398 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Can anyone help to do timer in Ajax with php?

Expand|Select|Wrap|Line Numbers
  1.  <script language="Javascript">
  2.  
  3.         function postRequest(strURL) {
  4.  
  5.     var xmlHttp;
  6.  
  7.         if (window.XMLHttpRequest) { // Mozilla, Safari, ...
  8.  
  9.          var xmlHttp = new XMLHttpRequest();
  10.  
  11.        } else if (window.ActiveXObject) { // IE
  12.  
  13.          var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  14.  
  15.        }
  16.  
  17.     xmlHttp.open('POST', strURL, true);
  18.  
  19.     xmlHttp.setRequestHeader('Content-Type', 
  20.          'application/x-www-form-urlencoded');
  21.  
  22.     xmlHttp.onreadystatechange = function() {
  23.  
  24.         if (xmlHttp.readyState == 4) {
  25.  
  26.             updatepage(xmlHttp.responseText);
  27.  
  28.         }
  29.  
  30.     }
  31.  
  32.     xmlHttp.send(strURL);
  33.  
  34.         }
  35.  
  36.  
  37.         function updatepage(str){
  38.  
  39.     document.getElementById("result").innerHTML = 
  40.  
  41.     "<font color='red' size='5'>" + str + "</font>";;
  42.  
  43.         }
  44.  
  45.         function showCurrentTime(){
  46.  
  47.     var rnd = Math.random();
  48.  
  49.     var url="time.php?id="+rnd;
  50.  
  51.     postRequest(url);
  52.  
  53.         }
  54.  
  55.         </script>
I did code like that for start bid process by using ajax, But its not working. If any one know regarding this please give me a solution.

Thanks,
Madhi
Aug 14 '10 #1
1 1591
johny10151981
1,059 1GB
Check your line 17 and line 32

in line 17 you are suppose to set the url but in line 32 obviously not the same url. in line 32 you need to set URI.
here is a sample of uri
Expand|Select|Wrap|Line Numbers
  1. xmlHttp.send("name=johny&id=10&Title="+escape("Software Developer"));
But there is a little trouble with escape it does not encode "/" and "+".

to do this you can replace "/" with "%2F" and "+" with "%2B". To see more detail about url encode you can follow the link.
Aug 14 '10 #2

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

Similar topics

3
by: darrel | last post by:
Anyone using Ajax with .net? Are there any controls/tools that make building with ajax easier or is it, for now, just a matter of connecting the javascript to the back end manually as needed? ...
7
by: BeeRich | last post by:
Hi folks. I built an ajax.updater reply in a website on a Mac, and she works fine. It's a simple reply, the html supplied is correct, and I also supply the target DIV as well. Just wondering...
3
by: SimonPlatten | last post by:
Hi, I'm a software engineer working in the offshore industry, I've been coding in various languages professionally since 1987. In my present employment I am working with control systems in the...
0
by: hzq3554055 | last post by:
i am novice,guess the following code can work combineing with server- side code ,but chaos ï¼›somewhere to me is great<script> var relationObject = {timer: null, key: ""}; function...
10
by: paulie | last post by:
Hi, I have been experiencing an issue when trying to use AJAX to reload a DIV area using a timer of 2000ms, which contains a html page with another DIV and javascript. Scenario -------------...
1
by: Chris Zopers | last post by:
Hello, I have an asp:UpdatePanel with some controls in it. The UpdatePanel has a Timer as a trigger and a button inside the UpdatePanel as a trigger. All works fine, but sometimes I get the...
5
by: fjm | last post by:
Hi everyone, I usually hang out on the php side because its what I know, but I am faced with a problem that I honestly have no idea how to solve and figured I would try my luck over here. I am hoping...
6
by: aliusmankhan | last post by:
Hi all I have developed an online testing system, Its time based test, I used AJAX TIMER to show the user that how much time left for the test, But when AJAX timer refresh in every sec, it makes...
22
by: canabatz | last post by:
Hi all! i got a countdown timer for auctions that runing. i got a DIV that refreshs every 4 seconds that DIV is refreshed by ajax ,the file that is refreshed is timer.php for example!! my...
1
by: ramanagosu | last post by:
hi please help me, I am doing project on online bidding using php it display's product details like image,price (in dollers ) and bidder name ,time seconds(00h:00m:00s), if bidder bid that...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.