473,382 Members | 1,717 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,382 software developers and data experts.

precedence for my ajax and javascript

Avatar19
Hi there,

I have a class that calls a dynamic countdown on my webpage.
when I call the class it looks like this.

Expand|Select|Wrap|Line Numbers
  1. <script type='text/javascript'>
  2. var futuredate=new cdtime("contain","April 21, 2011 12:55:55")
  3.                     futuredate.displaycountdown("days", formatresults)
  4. </script>
  5.  

A quick explanation: 'contain' is the div in which the class appears, and "April 21, 2011 12:55:55" is the future date set for countdown.
the 'days' and 'formatresults' is just the format that the countdown is displayed in.

now ideally what I am trying to do is instead of hard-coding my dates into my class like this, I want to pull the date from my database as a variable using Ajax. that function looks like this.
Expand|Select|Wrap|Line Numbers
  1. <script type='text/javascript'>
  2. var myret;
  3. function get_bid(div_id)
  4.  
  5. {
  6. if (div_id == 'contain')
  7. {
  8. var pass = 'apple_01';
  9. else if (div_id == 'contain2')
  10. {
  11. var pass = 'mp3_01';
  12. }
  13. else if (div_id == 'contain3')
  14. {
  15. var pass = 'car_01';
  16. }
  17. else if (div_id == 'contain4')
  18. {
  19. var pass = 'blackberry_01';
  20. }
  21. var xmlhttp;
  22. if (window.XMLHttpRequest)
  23.   {// code for IE7+, Firefox, Chrome, Opera, Safari
  24.   xmlhttp=new XMLHttpRequest();
  25.   }
  26. else
  27.   {// code for IE6, IE5
  28.   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  29.   }
  30. xmlhttp.onreadystatechange=function()
  31.   {
  32.   if (xmlhttp.readyState==4 && xmlhttp.status==200)
  33.     {
  34.  
  35.     var get_data = document.getElementById('test');
  36.     myret = xmlhttp.responseText;
  37.     get_data.innerHTML = myret;
  38.  
  39.     }
  40.  
  41.   }
  42. xmlhttp.open("GET","bid_data.php?q="+pass,true);
  43. xmlhttp.send(null);
  44.  
  45. }
  46.  
  47. </script>
  48.  
the variable myret contains the date variable that I want to use in my countdown class. i.e. I want to replace the hard-coded date with myret.
Expand|Select|Wrap|Line Numbers
  1. var futuredate=new cdtime("contain",myret)
  2.                     futuredate.displaycountdown("days", formatresults)
  3.  
I know myret is returning the correct information cos I just inserted it into a test div.

but when I use it in my countdown class, it returns 'not defined' on my web page.

Please could someone help me, I have been trying to use firebug to see what is being called when but I am super confused!!
Thank you so much for your help

Avatar19
Apr 20 '11 #1

✓ answered by JKing

Try giving myret a default value and see what happens. If the default value is displayed and not the pulled date then the ajax is finishing after the javascript has been processed.

12 1845
can anyone give me any thoughts/ help????
Apr 22 '11 #2
JKing
1,206 Expert 1GB
Do you have a link to the page in question? Having something to work with may be more helpful.
Apr 25 '11 #3
I can't give a link as far as I know cos it's not live on the web, I am developing on my laptop, but here is the actual file and a screen shot of whats returned.

The information you need is btwn lines 219-236.
lines 146,147,187,188 hold the divs that display the countdowns.
I can include the countdown class if needs be, just let me know.
Expand|Select|Wrap|Line Numbers
  1. <?
  2.  
  3. require('database/login_check.php');
  4. require('collect_sessioncvars.php');
  5. $_SESSION['url'] =  curPageURL();
  6.  
  7.  
  8. //echo $logged_in.'<br>',$logged_incorrect.'<br>',$username.'<br>',$credits.'<br>',$email.'<br>' ;
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15. ?>
  16. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  17. <html xmlns="http://www.w3.org/1999/xhtml">
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  20. <title>Zebra Spots</title>
  21. <link rel="stylesheet" href="css/index.css" type="text/css" />
  22. <script type='text/javascript' src = 'http://localhost/zebra/database/js/win.js'>
  23. </script>
  24. <script type='text/javascript' src = 'http://localhost/zebra/database/js/handler.js'>
  25. </script>
  26.  
  27. <script type='text/javascript' src = 'http://localhost/zebra/database/js/cdclass.js'>//countdown
  28. </script>
  29.  
  30.  
  31. <script type='text/javascript'>
  32.  
  33.  
  34. function toggle_website()
  35. {
  36.  
  37. var login = document.getElementById('regbar');
  38. var incorrect = document.getElementById('inc_loginmsg');
  39. var login_form = document.getElementById('loginform');
  40. var login_info = document.getElementById('login_info');
  41.  
  42.  
  43. if ('<? echo $logged_in?>' =='true' )
  44. {
  45. login.style.display = 'none';
  46. login_form.style.display = 'none';
  47. login_info.style.display = '';
  48.  
  49. }
  50. else if ('<? echo $logged_in?>' == 'false')
  51. {
  52. login.style.display = '';
  53. }
  54. if ('<? echo $logged_incorrect?>' == 'false')
  55. {
  56. incorrect.style.display = 'none';
  57. }
  58. }
  59. </script>
  60.  
  61.  
  62. <script type='text/javascript'>
  63. function raise_alert()
  64. {
  65. alert("You must be logged in to bid!!!");
  66. }
  67. </script>
  68.  
  69. </head>
  70.  
  71. <body  onload = "toggle_website()">
  72.  
  73. <div id="container">
  74.     <div id="header">
  75.         <h1><a href="index.php">Zebra Spots</a></h1>
  76.         <h2>bid spotting at it's best</h2>
  77.         <div class="clear"></div>
  78.     </div>
  79.  
  80.     <div id="nav" >
  81.     <ul>
  82.             <li class="selected"><a href="index.php">Home</a></li>
  83.             <li><a href="buyspots.php">Buy Spots</a></li>
  84.             <li><a href="help.php">Help</a></li>
  85.             <li><a href="contact.php">Contact</a></li>
  86.             <span id ='regbar' style = 'display:' ><li ><a href="registration.php">Register</a></li></span>
  87.             </ul>
  88.     </div>
  89.     <div id="body" style='display:'>
  90.  
  91.         <div id = 'loginform' style = 'display:'>
  92.         <form action = "database/login.php" method ="POST" name = 'loginform' >
  93.         <b>email</b>&nbsp <input size = "15px" type="text" onfocus="if(this.value=='Your email')this.value='';" value="Your email" name="email">&nbsp 
  94.         <b>password</b>&nbsp <input type = "password" onfocus="if(this.value=='*********')this.value='';" name = "password" value = '*********' size = "15px" />&nbsp 
  95.         <input  type = "submit" value = "Login"  />        
  96.         <form/>    
  97.         </div>
  98.         <p></p>
  99.  
  100.         <div id = 'login_info' style = 'display:none' align = ''>
  101.         <h2>    Welcome,&nbsp   <? echo $username ?> &nbsp&nbsp&nbsp  <span style=color:green><? echo $credits ?> credits </span>&nbsp&nbsp&nbsp <a href='database/logout.php'>logout</a> </h2> 
  102.  
  103.  
  104.         <p></p>
  105.         </div>
  106.  
  107.         <div id ='inc_loginmsg'>
  108.         <span  ><h2 style=color:red>Incorrect Email or Password</h2><a href = 'password_forgot.php'>forgot password?</a></span>
  109.         <p></p>
  110.         </div>
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.             <div id="content">
  118.                 <h1><center>Current bids</center></h1>
  119.                 <div class="box">
  120.  
  121.  
  122.                 <table>
  123.                     <tr>
  124.  
  125.                         <div id='auction1_price'><td align='center'><div id='auction1retail'></div></td></div>
  126.                         <div id='auction2_price'><td align='center'><div id='auction2retail'></div></td></div>
  127.  
  128.                     </tr>
  129.  
  130.                     <tr>
  131.  
  132.                         <div id='auction1_price'><td align='center'><div id='auction1name'></div></td></div>
  133.                         <div id='auction2_price'><td align='center'><div id='auction2name'></div></td></div>
  134.  
  135.                     </tr>
  136.  
  137.                     <tr>
  138.  
  139.                         <div id='auction1'><td align='center'><div id='auction1picture'><img src ="images/ipad2.jpg" width = "180px"/></div></td></div>
  140.                         <div id='auction2'><td align='center'><div id='auction2picture'><img src ="images/coby-mp-3.jpg" width = "180px"/></div></td></div>
  141.  
  142.                     </tr>
  143.  
  144.                     <tr>
  145.  
  146.                         <td align='center'><div id='contain'></div></td>
  147.                         <td align='center'><div id='contain2'></div></td>
  148.  
  149.                     </tr>
  150.  
  151.                     <tr>
  152.  
  153.                         <td align='center'><div id = 'username_auction1'>Michell2</div></td>
  154.                         <td align='center'><div id = 'username_auction1'>Assent</div></td>    
  155.  
  156.                     </tr>
  157.  
  158.                     <tr>
  159.  
  160.                         <td align='center'><div><input type = 'button' value = "bid now" id = "auction1_button" onclick="raise_alert()"></div></td>
  161.                         <td align='center'><div><input type = 'button' value = "bid now" id = "auction2_button" onclick="raise_alert()"></div></td>
  162.  
  163.                     </tr>
  164.  
  165.                     <tr>
  166.  
  167.                         <div id='auction1_price'><td align='center'><div id='auction3retail'></div></td></div>
  168.                         <div id='auction2_price'><td align='center'><div id='auction4retail'></div></td></div>
  169.  
  170.                     </tr>
  171.                     <tr>
  172.  
  173.                         <div id='auction1_price'><td align='center'><div id='auction3name'></div></td></div>
  174.                         <div id='auction2_price'><td align='center'><div id='auction4name'></div></td></div>
  175.  
  176.                     </tr>
  177.  
  178.                     <tr>
  179.  
  180.                         <div id='auction3'><td align='center'><div id='auction3picture'><img src ="images/blackberry8110.jpg" width = "180px"/></div></td></div>
  181.                         <div id='auction4'><td align='center'><div id='auction4picture'><img src ="images/cars_07.jpg" width = "180px"/></div></td></div>
  182.  
  183.                     </tr>
  184.  
  185.                     <tr>
  186.  
  187.                         <td align='center'><div id='contain3'></div></td>
  188.                         <td align='center'><div id='contain4'></div></td>
  189.  
  190.                     </tr>
  191.  
  192.                     <tr>
  193.  
  194.                         <td align='center'><div id = 'username_auction4'>Avatar19</div></td>
  195.                         <td align='center'><div id = 'username_auction1'>Kraken34</div></td>    
  196.  
  197.                     </tr>
  198.  
  199.                     <tr>
  200.  
  201.                         <td align='center'><div><input  type = 'button' value = "bid now" id = "auction3_button" onclick="raise_alert()"></div></td>
  202.                         <td align='center'><div><input type = 'button' value = "bid now" id = "auction4_button" onclick="raise_alert()"></div></td>
  203.  
  204.                     </tr>
  205.  
  206.                     <tr><td><div id = 'test'></div></td></tr>
  207.  
  208.  
  209.                 </table>
  210.  
  211.                 </div>
  212.  
  213.  
  214.             </div>
  215.         <script type ='text/javascript'>
  216.  
  217.  
  218.                 </script>
  219.                 <script>    
  220.                     get_bid('contain2');        
  221.                     //var futuredate=new cdtime("contain","April 22, 2011 13:10:00")
  222.                     var futuredate=new cdtime("contain",myret)
  223.                     futuredate.displaycountdown("days", formatresults)
  224.  
  225.  
  226.                 </script>
  227.                 <script>
  228.                     var futuredate=new cdtime("contain2","April 28, 2011 12:55:55")
  229.                     futuredate.displaycountdown("days", formatresults)
  230.                 </script>
  231.                 <script>
  232.                     var futuredate=new cdtime("contain3","April 25, 2011 19:00:22")
  233.                     futuredate.displaycountdown("days", formatresults)
  234.                 </script>
  235.                 <script>
  236.                     var futuredate=new cdtime("contain4","April 25, 2011 19:00:05")
  237.                     futuredate.displaycountdown("days", formatresults)
  238.                 </script>
  239.         <div class="sidebar">
  240.             <ul>    
  241.  
  242.  
  243.  
  244.                 <li>
  245.                    <center> <h4>About Zebra Spots</h4></center>
  246.                     <ul>
  247.                         <li>
  248.                             <p style="margin: 0;"><strong>Zebra Spots</strong> is a online bidding Site developed for people who sre willing to acquire cutting edge technology and goods for a fraction of the price.
  249.                             As a company we pride ourselves in delivering a service that is both secure and accesible to users, so that you can have peace of mind while while enjoying our online service</p>
  250.                         </li>
  251.                     </ul>
  252.                 </li>
  253.  
  254.  
  255.  
  256.                 <li>
  257.                     <center><h4>Zebra on the net</h4></center>
  258.                     <ul>
  259.                         <li><a href="#" title="Blogger"><strong>Check out our blog</strong></a> - All the people whom Zebra spots have made<strong> big winners</strong>, you could be next!!</li>
  260.                         <li><a href="#" title="Youtube"><strong>Our youtube adventure</strong></a> - Testify<strong> about your experience</strong></li>
  261.                         <li><a href="#" title="Youtube"><strong>Tweet your experience</strong></a> - Tweet <strong>yah or nah!!</strong></li>
  262.                     </ul>
  263.                 </li>
  264.  
  265.             </ul> 
  266.         </div>
  267.         <div class="clear"></div>
  268.     </div>
  269.     <div id="footer">
  270.         <div class="footer-content">
  271.  
  272.                 <span class="sitename">Zebra Spots</span>
  273.                     <p class="footer-links">
  274.  
  275.                     <a href="#container" class="backtotop">Back to top</a>
  276.                     </p>
  277.         </div>
  278.         <div class="footer-bottom">
  279.             <p>&copy; Zebra Spots 2011. Website Design by &nbsp <a href="http://www.spyka.net">Free CSS Templates</a> | <a href="http://www.justfreetemplates.com">Free Web Templates</a></p>
  280.          </div>
  281.  
  282.     </div>
  283. </div>
  284. </body>
  285. </html>
  286.  
  287.  
thanks for any help, if I need to include anything else for further reference please let me know. I might be able to put this up on the server so you can see but I am not sure when.
Apr 25 '11 #4
JKing
1,206 Expert 1GB
I can't really offer too many suggestions. You need to debug it.

First off I would do the following:
Is the value of myret correct?
Is the format of the value of myret correct?

If both of those checkout I would move on to how it is being handled by your cdtime class. Likely the error will be here if not in the former.
Apr 25 '11 #5
perhaps you can offer some advice on a more focused question.
I have included a pdf attachment of what I am explaining.

I believe the problem lies with the fact that my countdownclass is using the variable myret before it can be set. which is confusing me. Both my ajax func that collects my database info and my cd class are placed in my header. My ajax looks like
Expand|Select|Wrap|Line Numbers
  1. <script type='text/javascipt'>
  2. var myret;
  3. function get_bid(div_id)
  4.  
  5. {
  6. if (div_id == 'contain')
  7. {
  8. var pass = 'apple_01';
  9. else if (div_id == 'contain2')
  10. {
  11. var pass = 'mp3_01';
  12. }
  13. else if (div_id == 'contain3')
  14. {
  15. var pass = 'car_01';
  16. }
  17. else if (div_id == 'contain4')
  18. {
  19. var pass = 'blackberry_01';
  20. }
  21. var xmlhttp;
  22. if (window.XMLHttpRequest)
  23.   {// code for IE7+, Firefox, Chrome, Opera, Safari
  24.   xmlhttp=new XMLHttpRequest();
  25.   }
  26. else
  27.   {// code for IE6, IE5
  28.   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  29.   }
  30. xmlhttp.onreadystatechange=function()
  31.   {
  32.   if (xmlhttp.readyState==4 && xmlhttp.status==200)
  33.     {
  34.  
  35.     var get_data = document.getElementById('test');
  36.     myret = xmlhttp.responseText;
  37.     get_data.innerHTML = myret;
  38.  
  39.     }
  40.  
  41.   }
  42. xmlhttp.open("GET","bid_data.php?q="+pass,true);
  43. xmlhttp.send(null);
  44.  
  45. }
  46. </script>
  47.  
As you can see in this part of my ajax
Expand|Select|Wrap|Line Numbers
  1. var get_data = document.getElementById('test');
  2.     myret = xmlhttp.responseText;
  3.     get_data.innerHTML = myret;
  4.  
I have set a test div = the value of myret whatever that is. In this case it is a date time stamp that is stored in my db.
So what really confuses me is that the 'test' div that I use to check if the value is correct outputs exactly want I want
Expand|Select|Wrap|Line Numbers
  1. get_data.innerHTML = myret;
but when I use myret in the body of my page it appears as 'undefined'.
This is how I am calling it on my page.
Expand|Select|Wrap|Line Numbers
  1. <script type='text/javascript'>
  2. var futuredate=new cdtime("contain",myret)                    futuredate.displaycountdown("days", formatresults)
  3. </script>
  4.  
and this is how a normal call of the same instance would look without using the variable myret.
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. var futuredate=new cdtime("contain","April 28, 2011 12:55:55")            futuredate.displaycountdown("days", formatresults)
  3. </script>
  4.  
Thanks for the help you are giving JKing, I have tried to use firebug to see whats happening but I still have no clue!
Attached Files
File Type: pdf webpage.pdf (19.2 KB, 223 views)
Apr 26 '11 #6
JKing
1,206 Expert 1GB
What order are you placing all of these in the header?
Apr 26 '11 #7
the ajax 'function get_bid()' is placed after the cdclass 'http://localhost/zebra/database/js/cdclass.js'
my head looks like this:
Expand|Select|Wrap|Line Numbers
  1. <head>
  2. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  3. <title>Zebra Spots</title>
  4. <link rel="stylesheet" href="css/index.css" type="text/css" />
  5.  
  6. <script type='text/javascript' src = 'http://localhost/zebra/database/js/win.js'>
  7. </script>
  8. <script type='text/javascript' src = 'http://localhost/zebra/database/js/handler.js'>
  9. </script>
  10.  
  11. <script type='text/javascript' src = 'http://localhost/zebra/database/js/cdclass.js'>//countdown
  12. </script>
  13.  
  14. <script type='text/javascipt'>
  15. var myret;
  16. function get_bid(div_id)
  17.  
  18. {
  19. if (div_id == 'contain')
  20. {
  21. var pass = 'apple_01';
  22. else if (div_id == 'contain2')
  23. {
  24. var pass = 'mp3_01';
  25. }
  26. else if (div_id == 'contain3')
  27. {
  28. var pass = 'car_01';
  29. }
  30. else if (div_id == 'contain4')
  31. {
  32. var pass = 'blackberry_01';
  33. }
  34. var xmlhttp;
  35. if (window.XMLHttpRequest)
  36.   {// code for IE7+, Firefox, Chrome, Opera, Safari
  37.   xmlhttp=new XMLHttpRequest();
  38.   }
  39. else
  40.   {// code for IE6, IE5
  41.   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  42.   }
  43. xmlhttp.onreadystatechange=function()
  44.   {
  45.   if (xmlhttp.readyState==4 && xmlhttp.status==200)
  46.     {
  47.  
  48.     var get_data = document.getElementById('test');
  49.     myret = xmlhttp.responseText;
  50.     get_data.innerHTML = myret;
  51.  
  52.     }
  53.  
  54.   }
  55. xmlhttp.open("GET","bid_data.php?q="+pass,true);
  56. xmlhttp.send(null);
  57.  
  58. }
  59. </script>
  60. <script type='text/javascript'>
  61.  
  62.  
  63. function toggle_website()
  64. {
  65.  
  66. var login = document.getElementById('regbar');
  67. var incorrect = document.getElementById('inc_loginmsg');
  68. var login_form = document.getElementById('loginform');
  69. var login_info = document.getElementById('login_info');
  70.  
  71.  
  72. if ('<? echo $logged_in?>' =='true' )
  73. {
  74. login.style.display = 'none';
  75. login_form.style.display = 'none';
  76. login_info.style.display = '';
  77.  
  78. }
  79. else if ('<? echo $logged_in?>' == 'false')
  80. {
  81. login.style.display = '';
  82. }
  83. if ('<? echo $logged_incorrect?>' == 'false')
  84. {
  85. incorrect.style.display = 'none';
  86. }
  87. }
  88. </script>
  89.  
  90.  
  91. <script type='text/javascript'>
  92. function raise_alert()
  93. {
  94. alert("You must be logged in to bid!!!");
  95. }
  96. </script>
  97.  
  98. </head>
  99.  
  100.  
with countdown class above my ajax
and then with the countdown class being called in my body as i showed in previous posts.
Apr 26 '11 #8
JKing
1,206 Expert 1GB
Are there any errors being shown in firebug?

Also you are missing an 'r' in your script tag type="text/javascript"
Expand|Select|Wrap|Line Numbers
  1. <script type='text/javascipt'>
  2. var myret;
  3. function get_bid(div_id)
  4.  
Apr 26 '11 #9
oh thanks, but thats jus a lil error in pasting it here, its fine in my file.
When I run it through firebug, it jus says that var myret is undefined, this is at the location that you pasted in your post. but as for errors, I can't see any
Apr 26 '11 #10
JKing
1,206 Expert 1GB
Try giving myret a default value and see what happens. If the default value is displayed and not the pulled date then the ajax is finishing after the javascript has been processed.
Apr 26 '11 #11
OK so I set myret = "April 28, 2011 12:55:55" like so"
Expand|Select|Wrap|Line Numbers
  1. <script type='text/javascript'>
  2.  
  3. var myret "April 28, 2011 12:55:55";
  4. function get_bid(div_id)
  5.  
  6. {
  7. if (div_id == 'contain')
  8. {
  9. var pass = 'apple_01';
  10. else if (div_id == 'contain2')
  11. {
  12. var pass = 'mp3_01';
  13. }
  14. else if (div_id == 'contain3')
  15. {
  16. var pass = 'car_01';
  17. }
  18. else if (div_id == 'contain4')
  19. {
  20. var pass = 'blackberry_01';
  21. }
  22. var xmlhttp;
  23. if (window.XMLHttpRequest)
  24.   {// code for IE7+, Firefox, Chrome, Opera, Safari
  25.   xmlhttp=new XMLHttpRequest();
  26.   }
  27. else
  28.   {// code for IE6, IE5
  29.   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  30.   }
  31. xmlhttp.onreadystatechange=function()
  32.   {
  33.   if (xmlhttp.readyState==4 && xmlhttp.status==200)
  34.     {
  35.     var myret = xmlhttp.responseText;
  36.     var get_data = document.getElementById('test');
  37.  
  38.     get_data.innerHTML = myret;
  39.  
  40.     }
  41.  
  42.   }
  43. xmlhttp.open("GET","bid_data.php?q="+pass,true);
  44. xmlhttp.send(null);
  45.  
  46. }
  47. </script>
  48.  
and when i used it like so:
Expand|Select|Wrap|Line Numbers
  1. <script>
  2.  
  3.                     var futuredate=new cdtime("contain3",myret)
  4.                     futuredate.displaycountdown("days", formatresults)
  5.  
  6.                 </script>
  7.  
it works exactly how want it to except now it is a static value which is not coming form my db.
what can I do to make sure my xmlhttp.responseText is used as this value and not this static string???
thanks for your help again btw!!!
Apr 27 '11 #12
Hey JKIng just posting here to say that I solved my problem!, the solution looked like this:
I made two ajax functions controlling my bids, one was set to run on page load which would initialize my timers ad one was set as an onclick condition in my bid buttons.
I placed everything in my head and it worked great!!


Expand|Select|Wrap|Line Numbers
  1. <script type='text/javascript'>// countdown function
  2.  
  3.  
  4.  
  5. function get_bid(div_id)
  6. {
  7. var pass = div_id;
  8. var xmlhttp;
  9. if (window.XMLHttpRequest)
  10. {// code for IE7+, Firefox, Chrome, Opera, Safari
  11.         xmlhttp=new XMLHttpRequest();
  12. }
  13. else
  14. {// code for IE6, IE5
  15.         xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  16. }
  17.         xmlhttp.onreadystatechange=function()
  18. {
  19. if (xmlhttp.readyState==4 && xmlhttp.status==200)
  20. {
  21.         myret = xmlhttp.responseText;
  22.         var futuredate=new cdtime(div_id,myret)
  23.         futuredate.displaycountdown("days", formatresults)
  24.  
  25.  
  26. }
  27.  
  28. }
  29. xmlhttp.open("GET","bid_data.php?q="+pass,true);
  30. xmlhttp.send(null);
  31.  
  32. }
  33.  
  34.  
  35. function update_bid(div_id)
  36. {
  37. {
  38. var pass = div_id;
  39. var xmlhttp;
  40. if (window.XMLHttpRequest)
  41. {// code for IE7+, Firefox, Chrome, Opera, Safari
  42. xmlhttp=new XMLHttpRequest();
  43. }
  44. else
  45. {// code for IE6, IE5
  46. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  47. }
  48. xmlhttp.onreadystatechange=function()
  49. {
  50. if (xmlhttp.readyState==4 && xmlhttp.status==200)
  51. {
  52. myret = xmlhttp.responseText;
  53. var futuredate=new cdtime(div_id,myret)
  54. futuredate.displaycountdown("days", formatresults)
  55. }
  56.  
  57. }
  58. xmlhttp.open("GET","update_bid.php?q="+pass,true);
  59. xmlhttp.send(null);
  60.  
  61. }
  62.  
  63. }
  64.  
  65.  
  66. </script>
  67.  
  68.  
  69. <script type='text/javascript'>// countdowns
  70.     get_bid('apple_01');
  71.     get_bid('mp3_01');
  72.     get_bid('car_01');
  73.     get_bid('blackberry_01');    
  74. </script>
  75.  
  76.  
I would just like to say thanks so much for the effort you put in to help me solve the issue, I appreciate it! :) If you want check the working product , you can visit
http://sats.cs.wits.ac.za/~382956
although unless you check it within the next 9 hrs, the timers will run out an you won't be able to see it in action.
Apr 30 '11 #13

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

Similar topics

2
by: sneill | last post by:
MXLogic, a Denver, Colorado based software company with 100+ employees is looking for candidates with **VERY STRONG** AJAX, Javascript, HTML, and CSS skills. Our company is building...
4
by: Trip | last post by:
Please if someone can help me !!! I need client and server code(principle based on AJAX) for next problem: i have 3 <select> tags on html page.(it must be NO page reload(callback) only...
1
by: Tom Kelly - Tampa | last post by:
For everyone who wants to watch Ajax in action using ASP.NET. I have come across a method to debug ajax script into server-side code, I am not sure if it will work with classic ASP, but it may...
1
by: Terry Smith | last post by:
I have individual Javascript files at the component level for components that need to make AJAX calls to the server. The server returns a list of XML elements with the name of the control whose...
3
by: kariach | last post by:
Hello, I am writing a web app that collects some user input and an optional image filename. When the user clicks submits, I use an asynchronous XML HTTP call to a backend asp.net handler to...
2
by: Yorian | last post by:
Hi, Another problem another question (as usual). I want to retrieve data through ajax, within the data there is some javascript which needs to be used (I figured that one out using eval ())....
2
by: Nathan Sokalski | last post by:
I am moving my website from my machine to my webhost, and need some help with what extra files I need to include due to the fact that I used AJAX in my site. Everything on the site is obviously...
3
by: farukcse | last post by:
Hi, Can any one tell me how to assign a php variable value using ajax / javascript? Regards, Faruk Chowdhury
4
by: djemmers | last post by:
hi all, I have a site running where ppl can add their events into a database. when they choose a country from a listbox, a second listbox (province gets filled with options depending on the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.