I am trying to use AjaxForm to update data. On first call it works great and updates the html text in my by id.
<script type="text/javascript">
$( document ).ready(function() {
$('.entry_form').ajaxForm(function(data) {
$("#results").html(data);
});
$('.submitclosest').on('click', function(e) {
e.preventDefault();
$(this).closest('form').submit();
});
});
</script>
On my fetching file I got this line:
<script>$('#sales_<?=$tid;?>_<?=$position_json;?>').html('<?php ShowSlot($tid, $position_json);?>');</script>
And I got this on the functions file:
function ShowSlot($tid, $position_json)
{
?><form action="fetch/add_entry.php" method="post" class="entry_form"><input type="hidden" name="tid" value="<?=$tid;?>" /><input type="hidden" name="position" value="<?=$position_json;?>" /><a href="#" class="submitclosest"><i class="fas fa-user-plus"></i></a></form><?php
}
Any idea why it works only on first refresh?