I have a list of categorie. When I click on some category to fire an AJAX request the first time the request is not sent. When i click a second time it works great. Here is my code
<?php foreach($this->category as $value) { ?>
<li data-cid=<?= $value['cat_id']?> class="cid">
<a href="http://localhost/mvc/viewbycat/index/<?= $value['cat_id'] ?>">
<?= $value['cat_name']?>
</a>
</li>
<?php } ?>
$(document).ready(function () {
var catid;
var count = 0;
$('li.cid').click(function (e) {
count = 0;
var limit = 6;
var offset = 0;
e.preventDefault();
$("#main").empty();
catid = $(this).attr('data-cid');
displayRecords1(limit, offset, catid);
});
Thanks for help!