Send value to a php $_GET[] from jquery tamperred navi.
Hi everyone,
this is the html navigation, generated from a php-Script in index.php
-
<ul id="navi" class="nav">
<li class="level_1" id="501"><a href="index.php?id=501">root1</a></li>
<li class="level_1" id="502"><a href="index.php?id=502">root2</a>
<ul>
<li class="level_2" id="503"><a href="index.php?id=503">root2.2</a>
</ul>
</li>
<li class="level_1" id="504"><a href="index.php?id=504">root3</a></li>
</ul>
this is my jquery-function for it in index.php
-
$(document).ready(function() {
// live
$('#navi ul').hide();
$('#navi li').children('a').click(function(event) {
$(this).next().slideToggle(200);
$('ul',$(this).parent().siblings()).slideUp(200);
event.stopPropagation();
return false;
});
// try to send the id to index.php
$('#navi li').children('a').click(function(event) {
var li_ID = $(this).parent().attr('id'); // get the id
// alert(li_ID);
$.ajax({
type: "GET",
async: false,
url: "index.php",
data: "action=" + li_ID,
success: function(data){
id=data;
//alert(id);
}
});
});
});
this is the part to save the id in a php-variable in index.php
-
$show_id = $_GET['action'];
echo $show_id;
But I get no echo from this. How can I send data from the navigation to php, all in the same index.php
what I'm doing wrong?
thanks for any advice.