Hoping to implement an AJAX timer
Moderator: General Moderators
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
Hi Kieran,
I've been looking to do something very similar, except that I want a certain section of a page (within a div) to be filled with contents from a php page when I click on a link.
Taking the jquery code from your previous reply in the same thread, I added it to the onclick event of a link. Basically, the date and time should be displayed every time you click on the link.
I got it to work fine on Firefox, but it only works the first time the page is displayed when I test it on IE. Subsequent clicking of the link does not update the time displayed. Here is a link to the page.
http://hornet83.no-ip.org/sample/test
Why does it work correctly on Firefox but not on IE (6.0)???
Thanks,
Ray
I've been looking to do something very similar, except that I want a certain section of a page (within a div) to be filled with contents from a php page when I click on a link.
Code: Select all
<?php
$date=date('l dS \of F Y h:i:s A');
echo "<h1>$date</h1>";
?>Code: Select all
<html>
<head>
<title> your (my??) awesome page </title>
<meta name="Generator" content="EditPlus" />
<meta name="Author" content="Kieran Huggins - http://kieran.ca" />
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<h1>HELLO</h1>
<a href="#" onclick="$(function(){$('#ajaxDiv').load('sample.php');});">OPEN SESAME!</a>
<div id="ajaxDiv"></div>
</body>
</html>
http://hornet83.no-ip.org/sample/test
Why does it work correctly on Firefox but not on IE (6.0)???
Thanks,
Ray
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
Changing the code to
still didn't work on IE, works fine on firefox.
That must be some caching done by IE, since even refreshing the page (which clears the content of the DIV), still displays the data from when the link was first clicked on. Only closing the browser window and reopening the page clears the cache.
*sigh*... IE...*sigh*
Code: Select all
......xDiv').load('sample.php?');})...That must be some caching done by IE, since even refreshing the page (which clears the content of the DIV), still displays the data from when the link was first clicked on. Only closing the browser window and reopening the page clears the cache.
*sigh*... IE...*sigh*
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
it just hit me - you should be using
since the "$(function(){...});"is autoloader code.
Check out http://www.visualjquery.com/1.1.1.html - it's a great reference!
Code: Select all
<html>
<head>
<title> your (my??) awesome page </title>
<meta name="Generator" content="EditPlus" />
<meta name="Author" content="Kieran Huggins - http://kieran.ca" />
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<h1>HELLO</h1>
<a href="#" onclick="$('#ajaxDiv').load('sample.php');">OPEN SESAME!</a>
<div id="ajaxDiv"></div>
</body>
</html>Check out http://www.visualjquery.com/1.1.1.html - it's a great reference!
Taking out the autoload function still produced the same behaviour.....
Thanks for the VisualQuery link though. Looking under AJAX, I found another function called loadIfModified.
Great was my joy when I replaced
to
It worked on IE!!!! Well, my joy was cut short when it didn't work on Firefox using loadIfModified.
Modified my test page, with two links, one using the simple load and the other using loadIfModified. http://hornet83.no-ip.org/sample/test
Any ideas?
Thanks for the VisualQuery link though. Looking under AJAX, I found another function called loadIfModified.
Great was my joy when I replaced
Code: Select all
<a href="#" onclick="$('#ajaxDiv').load('sample.php');">OPEN SESAME!</a>Code: Select all
<a href="#" onclick="$('#ajaxDiv').loadIfModified('sample.php');">OPEN SESAME!</a>Modified my test page, with two links, one using the simple load and the other using loadIfModified. http://hornet83.no-ip.org/sample/test
Any ideas?