I have been trying to use/get the values from $_GET["_escaped_fragment_"]
in PHP in WAMP SERVER but it doesn't seem to work.
PHP Code:
$values = $_GET['_escaped_fragment_'];
if($values) {
echo "Values: ".$values;
}
JQuery Code:
$(function() {
$(window).hashchange(function() {
if(window.location.hash) {
var url = window.location.hash.split("#!");
carregar(url[1]);
}
});
$(window).hashchange();
});
function carregar(url){
$('#container').load('/'+url+".php",function(){
});
}
HTML Code:
<a href="/#!home">> Home</a>
<a href="/#!contato">> Contato</a><br>
<div id="container">
<?php
if($values) {
include $values.".php";
}
?>
</div>
Robots.txt
User-agent: *
Allow: /
So, if I click a link (home for ex.) it will be: localhost/#!home
, and it does loads the content from home.php
which display my home content.
Problem the PHP $_GET["_escaped_fragment_"]
doesn't get any values, even when I force to load the page(writing in the url and hitting Enter)
My Wamp Version:
Apache Version: 2.4.9
PHP Version: 5.5.12
MySQL Version: 5.6.17
Following on from my comments... You will need to do something like....
$(function() {
$(window).hashchange(function() {
if(window.location.hash) {
var url = window.location.hash.split("#!");
var realUrl = '/' + url[1] +
".php?_escaped_fragment_=/" + encodeURIComponent(window.location.hash);
$('#container').load(realUrl, function(){
// do stuff when finished
});
}
});
$(window).hashchange();
});