I am trying to get my predefined variable $_GET['loc'] Can anyone help me ? The problem is I don't want to disable my anchor tag for ajax using javascript. So what i did is I just added a hash-tag (#) on my href. The URL looks like this
http://localhost/test/onspecial/index.php#filter?loc=dn
What I need to attain is to access the $_GET['loc']. I really appreciate any help.
my href attribute looks like this
<a href="#filter?loc=dn"></a>
here is my full navbar in index.php and wanted to get the value of $_GET['loc'] for my other queries :
<div class="navbar">
<ul class="nav" id="nav">
<li><a href="index.php">home</a></li>
<li><a href="index.php">about us</a></li>
<li><a href="index.php">contact us</a></li>
<li class="dropdown">
<a id="drop_tog"href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-delay="1000" data-close-others="false">Location</a>
<ul class="dopdown-menu" id="loc">
<li id="loc1"><a tabindex="-1" href="#filter?loc=dc" >City</a></li>
<li id="loc1"><a tabindex="-1" href="#filter?loc=ds" >South</a></li>
<li id="loc1"><a tabindex="-1" href="#filter?loc=dn" >North</a></li>
</ul>
</li>
</ul>
</div>
javascript looks like this sending request on getresult.php :
$(document).ready(function(e) {
function getLoc(param){
//filter url
var encode = param.substring(7);
if(window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
}
else{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
document.getElementById("li_start").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET","getresult.php"+encode,false);
xmlhttp.send();
}
//handle anchor clicks
$("ul#location li a").click(function(){
var loc = $(this).attr("href");
getLoc(loc);
});
});