I want to load data from the database when i click on an a link. My links are data from a database. This is how I do it in my view:
<div id="wijken">
<ul>
<?php foreach($this->districts as $districts) : ?>
<li><a><?php echo $this->escape($districts->wijk); ?></a></li>
<?php endforeach; ?>
</ul>
</div>
This is how it looks:

Now I want that when you click on a link that I can load data and show data from the database depending on the link you clicked. How can I do this?
I tried it with javascript. Is it possible that you can load data with ajax call to an action in a controller?
My javascript:
$("#wijken ul li a").click(function(e){
var wijk = ($(this).text());
$.ajax({
type: "POST",
url: "index/test",
data: "wijk",
dataType: 'json',
success: function(rows)
{
alert("worked!");
},
error: function(error){
alert("didn't worked!");
}
});
Could this work or not?