I have a puzzling problem with trying to make an ajax/static state program. What I am trying to do is allow a static linked app have ajax dynamic urls and everything is kinda fine until a page refresh.
The problem:
PHP Does not see the hash so it only sees the original URI request. So PHP loads the original page but then JQuery (Javascript) replaces that page with the actual one I want after the #. Example:
url: localhost/index.php#!/search
It is fine to navigate to this page but pressing refresh php goes for:
url: localhost/index.php
and then javascript goes for:
url: #!/search
So I actually load two pages...which sucks.
This is a problem that must have occured and I notice facebook have done it to help load times (same reason I wanna do it). From the best I can tell they are able to reliably detect the hash and replace $_SERVER['REQUEST_URI'] with its contents so when you refresh you get localhost/search from localhost/index.php#!/search.
I was wondering if anyone has a little fix for this. I have looked in server side javascript but after a lot of googling I didn't really get a clear picture.
Thanks in advance
The browser itself doesn't even send the hash portion of the URL when it makes a request. You will still need to load two pages. The best you can do is make the initially loaded page a simple static HTML Ajax bootstrap. This way the initial pageload is cacheable, light on resources, and quick to load.