Display a list of categories:
<?php foreach($category as $cat) :?> <li><a class="cat" href="#" data-id="<?=$cat['cat_id']?>"><?=$cat['name']?></a></li> <?php endforeach?> Jquery:
$(function(){ var base_url = '<?php base_url();?>'; $('.cat').click(function(){ data={id: $('.cat').data('id')}; console.log(data); $.post(base_url+'getContentByCategory', data, function(){ }); }); Which link I wouldn’t click on, sends id = 1 always, although if you look in the browser, then id is different

catthat does not even have an attribute likedata-id- Alexey Shimansky