joecooper Posted October 25, 2013 Share Posted October 25, 2013 It is a countdown that eventually would get the new date to count down to from a MySQL query. But it can change often and needs to refresh every second. Live example: http://www.mp3joe.com Not sure why it keeps disapearing like it is. index.php: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <head> <script type="text/javascript">// <![CDATA[ $(document).ready(function() { $.ajaxSetup({ cache: false }); // This part addresses an IE bug. without it, IE will only load the first number and will never refresh setInterval(function() { $('#results').load('data.php'); }, 5000); // the "3000" here refers to the time to refresh the div. it is in milliseconds. }); // ]]></script> </head> <div id="results">Loading users...</div> data.php: <head> <link rel="stylesheet" href="jquery.countdown.css"> <style type="text/css"> #defaultCountdown { width: 240px; height: 45px; } </style> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.countdown.js"></script> <script type="text/javascript"> $(function () { var austDay = new Date(); austDay = new Date(austDay.getFullYear() + 1, 1 - 1, 26); $('#defaultCountdown').countdown({until: austDay}); $('#year').text(austDay.getFullYear()); }); </script> </head> <div id="defaultCountdown"></div> Quote Link to comment https://forums.phpfreaks.com/topic/283287-refreshing-countdown-makes-it-disappear/ Share on other sites More sharing options...
joecooper Posted October 26, 2013 Author Share Posted October 26, 2013 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/283287-refreshing-countdown-makes-it-disappear/#findComment-1455577 Share on other sites More sharing options...
Psycho Posted October 26, 2013 Share Posted October 26, 2013 The link you provided brings up a "server not found" error. But, looking at the code, a few things jump out at me. The index page seems incomplete - e.g. html tags are missing, no opening body tag, a javascript is outside the head tags, etc. So, assuming the index page is complete, the javascript is loading data into a div from the data.php page. But, the data.php page has HTML elements that already exist int he main page (e.g. HTML and HEAD tags. Several javascript includes as well as a function. That doesn't make sense to me. I'm sure your problem is with that. The JavaScript in the index page should not be getting new dynamic javascript to be run. Quote Link to comment https://forums.phpfreaks.com/topic/283287-refreshing-countdown-makes-it-disappear/#findComment-1455582 Share on other sites More sharing options...
joecooper Posted October 26, 2013 Author Share Posted October 26, 2013 Sorry, here is the link http://82.145.36.70/ So other than that the script is fine? Is there not a way to have a refreshing function that gets a single value for the date from another page? Rather than reload the clock script each time? Quote Link to comment https://forums.phpfreaks.com/topic/283287-refreshing-countdown-makes-it-disappear/#findComment-1455585 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.