I'm using the cakephp framework and the jquery infinitescroll plugin for loading the content dynamically. And each post has a link with an ajax action.
When a load the page there are 5 posts and the ajax links are working fine. But when a load 5 other posts with the infitescroll (ajax) the ajax link is not working.
It looks that the ajax function cannot find the id of the link but I don't find a solution.
<a href="/questions" onclick="return false"><i class="glyphicon glyphicon-circle-arrow-right" id="581617"></i></a>
<script type="text/javascript">
$(document).on("click","#581617",function(){
$.ajax({url: "the_url",
type:'post',
}) });
</script>
UPDATE: After making changes based on @ZacharyKniebel's solution, I am trying to write my selector to attach to links by ID using the below, which is not working. Can anyone tell me why?
"a > i.glyphicon.<?php echo $linkId;?>"