Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-07-2011, 07:25 PM   PM User | #1
Dan13071992
Regular Coder

 
Join Date: Dec 2010
Location: Kent, UK
Posts: 573
Thanks: 23
Thanked 10 Times in 10 Posts
Dan13071992 is an unknown quantity at this point
On load, auto refresh div not loading on page load

hi guys, this is the second thing ive attempted using jquery/ajax, so first, if im in the wrong place can someone please move this, and secondly, i have a script to auto refresh a div, its not coming up in the right place, plus its not loading on page load it waits a while before loading up. i will post the code below.

Code:
<script type="text/javascript">
<!--

function updateClock ( )
{
  var currentTime = new Date ( );

  var currentHours = currentTime.getHours ( );
  var currentMinutes = currentTime.getMinutes ( );
  var currentSeconds = currentTime.getSeconds ( );

  // Pad the minutes and seconds with leading zeros, if required
  currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
  currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

  // Choose either "AM" or "PM" as appropriate
  var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";

  // Convert the hours component to 12-hour format if needed
  currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

  // Convert an hours component of "0" to "12"
  currentHours = ( currentHours == 0 ) ? 12 : currentHours;

  // Compose the string for display
  var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;

  // Update the time display
  document.getElementById("clock").firstChild.nodeValue = currentTimeString;
}

// -->
</script>
<script src="http://ajax.googleapis.com/ajax/
libs/jquery/1.3.0/jquery.min.js"></script>
 <script>
function LOAD()
{
var auto_refresh = setInterval(
$('#loaddiv').load('inc-response.php');
}, 20000);
</script>




<body onLoad="updateClock(); setInterval('updateClock()', 1000 )" onLoad="LOAD();" >
the clock works fine loads on page load, however the auto refresh of the dive called loaddiv isnt loading on page load, the div is collecting a php file that it auto refreshes to see if the user has any new messages.

the other problem is that the div is coming above the country that the user is in when in the script its wrote in below it:

Code:
<div class="cat">
<img style="width: 100%;" src="game/site/site/table_top.gif">
<table class="cat" border="0" cellpadding="0" cellspacing="0" width="100%"><tbody><tr><td colspan="2" align="center"><?php echo date('l'); ?><br /><span id="clock">&nbsp;</span>
</td></tr><br /><tr><td colspan="2" align="center"><div id="1">
<?php echo "<a href='trainstation.php'>$fetchlocation->country</a>"; ?></div></td></tr>
<tr>
<div id="loaddiv">
</div>
</tr>
</tbody></table></div>
<br><img style="width: 100%;" src="game/site/site/table_bottom.gif"><br>
as im new to this, please help me as much as, so i can get a better understanding of it.

Thanks.
__________________
http://360-tactics.co.uk/forum/index.php

Crime-Wave

please post your code wrapped in tags
please post your PHP wrapped in tags
Dan13071992 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:25 PM.


Advertisement
Log in to turn off these ads.