I have a php script which shows me all folders - categories on my website:
echo "<ul>";
foreach(glob('category/*', GLOB_ONLYDIR) as $dir) {
$dir = str_replace('category/', '', $dir);
echo '<li class="button" onclick="reload();">'.$dir.'</li>';
};
echo "</ul>";
When I click on category JQuery reload a div with content of php file.
function reload(category) {
$("#content").load("send.php");
}
I want to send to that php file name of the category I have had clicked. How can I do that? Thanks for the answer
This should work :
echo "<ul>";
foreach(glob('category/*', GLOB_ONLYDIR) as $dir) {
$dir = str_replace('category/', '', $dir);
echo '<li class="button" onclick="reload(\''.$dir.\'');">'.$dir.'</li>';
};
echo "</ul>";
I added the $dir variable as a parameter of the reload function.
And then inside your reload function :
function reload(category) {
$("#content").load("send.php?category="+category);
}
Is this what you meant ? Hope it helped :)