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

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 09-07-2012, 05:47 PM   PM User | #1
durangod
Senior Coder

 
Join Date: Nov 2010
Posts: 1,191
Thanks: 217
Thanked 31 Times in 30 Posts
durangod is on a distinguished road
Reload Function

Hi, i have a graph on a page that has two options, if you click "sign up" it shows how many people signed up in the last 10 days.
If you click "login" it shows you how many people logged in the last 10 days.

Here is my delima, it defaults to "login" when i click signup the page reloads but graph does not change until i click the refresh
in the browser (my guess is that at first it is getting it from cache) when click refresh or f5 then it changes the graph

this happens vice versa too, the graph does not change content until i press f5 or refresh the browser.

So what i did is i did a function.


Code:
<script>
function reloadthepage()
  {
  location.reload(true)
  }
</script>
Then i put the line.

Code:
<a href="<?=$_SERVER['PHP_SELF']?>?gra=sign" onClick="reloadthepage()">Sign Up</a> - <a href="<?=$_SERVER['PHP_SELF']?>" onClick="reloadthepage()">Login</a></div><img src="mygraph.jpg">
But it is still not working until i press f5 or the refresh icon on the browser. I thought the "true" option forced it to get it from the server and not cache?

Any ideas here, thanks...
durangod is offline   Reply With Quote
Old 09-07-2012, 07:09 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,103
Thanks: 197
Thanked 2,421 Times in 2,399 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Try:-

onclick="window.location.reload(true)"

Or try specifying the page's href to ensure that the page is reloaded from the server:

window.location.reload(location.href);


Quizmaster: What character in A.A.Milne's "Winnie The Pooh" is named after his son?
Contestant: Pooh.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Users who have thanked Philip M for this post:
durangod (09-08-2012)
Old 09-08-2012, 02:21 AM   PM User | #3
durangod
Senior Coder

 
Join Date: Nov 2010
Posts: 1,191
Thanks: 217
Thanked 31 Times in 30 Posts
durangod is on a distinguished road
unfortunately that did not work either, so im not sure what the deal is. Im lost on this one but i will dig some more and see if i can find something to work, i dont know why it is not working.
durangod is offline   Reply With Quote
Old 09-08-2012, 07:30 AM   PM User | #4
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,103
Thanks: 197
Thanked 2,421 Times in 2,399 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by durangod View Post
unfortunately that did not work either, so im not sure what the deal is. Im lost on this one but i will dig some more and see if i can find something to work, i dont know why it is not working.
Sorry, I don't know either! It ought to work.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Old 09-08-2012, 10:01 AM   PM User | #5
hdewantara
Regular Coder

 
hdewantara's Avatar
 
Join Date: Aug 2009
Location: Jakarta, Indonesia.
Posts: 289
Thanks: 5
Thanked 40 Times in 40 Posts
hdewantara is an unknown quantity at this point
Untested...
But with no reloadthepage(), try to have a "different image" for same page?
Then I guess this would be easier be done through PHP, which look like the last line below:
PHP Code:
  ...
  <a href="<?=$_SERVER['PHP_SELF']?>?gra=sign" onClick="reloadthepage()">Sign Up</a> - 
  <a href="<?=$_SERVER['PHP_SELF']?>">Login</a>
</div>
<img src="mygraph.jpg?<?=rand()?>">
hdewantara 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 10:51 PM.


Advertisement
Log in to turn off these ads.