javascript - Reloading a page via AJAX when window.location=self.location doesn't work -


on homepage got:

<ul id="login">   <li> <a id="loginswitch" href="./login-page">log-in</a> | </li>   <li> <a id="signupswitch" href="./signup-page">sign-up</a> </li> </ul> 

via mootools, these anchor elements id once they're clicked, flashy div popup below them contains login or signup form (with methods stop propagation of events of course) , upon filling-up fields ajax call kicks in - that's supposed create session , reload page user have visual logged in , user-level-controls appears etc..

the ajax call initiated mootools ajax class , evalscripts option set true. ajax page returns script code:

<script type="text/javascript">window.location = self.location;</script> 

this system works - i'm wondering why if change anchors' href values href="#" scripts won't work anymore?

does have window?

did change property when clicked link or when event's propagation stopped??

window.location = self.location; 

this javascript executing.

when executes, browser being told replace value of window.location new value. not browsers react same way here.. work expect, others smart , compare 2 values. the browser knows page it's on, , knows you're asking go same page.

browser cache

the browser has copy of current page in cache. can talk server , ask whether page has in cache still valid. if cache valid, may decide not force reload of page. behind scenes, happens http headers. browsers , servers can communicate on http in many ways. in case, browser sends quick request server saying this:

get /stackoverflow.com/posts/196643/index.html http/1.1 host: www.stackoverflow.com user-agent: mozilla/5.0 if-modified-since: sun, 12 oct 2008 20:41:31 gmt 

this called conditional request. saying if-modified-since, browser saying, "give me file, if has been modified since last time saw it."

long story short, haven't explicitly told browser reload page.

here's how can:

location.reload( true ); 

the "true" optional parameter, forcing reload. browser won't @ cache.. say.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -