Page 2 of 2

Posted: Thu Jan 18, 2007 9:53 am
by impulse()
Sorted now.

Since 10am I've been looking for a script to do this and it's taken me untill now 4pm to find the only script that does that

http://codewalkers.com/tutorials/99/2.html

Thank you for your help.

Posted: Thu Jan 18, 2007 10:43 am
by Kieran Huggins
That's bad code, but I guess if it works...

Incidentally, you probably just had the wrong path to jQuery.js

Posted: Mon Feb 12, 2007 3:22 am
by Hornet83
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.

Code: Select all

<?php
   $date=date('l dS \of F Y h:i:s A');
   echo "<h1>$date</h1>";
?>
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.

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>
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

Posted: Mon Feb 12, 2007 3:55 am
by Kieran Huggins
Seems like IE is caching the result of the page for some reason - try changing the url to 'sample.php?'

Posted: Mon Feb 12, 2007 5:41 am
by Hornet83
Changing the code to

Code: Select all

......xDiv').load('sample.php?');})...
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*

Posted: Mon Feb 12, 2007 6:21 am
by Kieran Huggins
it just hit me - you should be using

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>
since the "$(function(){...});"is autoloader code.

Check out http://www.visualjquery.com/1.1.1.html - it's a great reference!

Posted: Mon Feb 12, 2007 6:42 am
by Hornet83
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

Code: Select all

<a href="#" onclick="$('#ajaxDiv').load('sample.php');">OPEN SESAME!</a>
to

Code: Select all

<a href="#" onclick="$('#ajaxDiv').loadIfModified('sample.php');">OPEN SESAME!</a>
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?