i have a page for view photos and users can submit comment on it
i write a js file name(ajax.js) to load new comment with ajax every 30 sec on that pages
i write another js file (name feed.js) for when user click on delete icon near every comment comment go hide and delete
codes feed.js:
$('a[cm-del]').click(function () {
var cmid = $(this).attr('cm-del');
var typeid = $(this).attr('data-type');
$('li[last-id=' + cmid + ']').effect('pulsate');
$('li[last-id=' + cmid + ']').hide(300);
$.post('/post/comment.php', {
cmdelete: cmid,
type: typeid
}, function () {});
});
codes ajax.js:
function getmorecmphoto() {
$('li[data-hiv]').hide();
var lastid = $('li[last-id]:last').attr('last-id');
if (lastid === '') {
var lastid = 0;
}
var oldcm = $('div[comments-id]').html();
var photoid = $('div[comments-id]').attr('comments-id');
$.post('/post/photo.php', {
lastid: lastid,
photoid: photoid
}, function (getlastcmphoto) {
$('div[comments-id]').html(oldcm + getlastcmphoto);
});
}
setInterval(getmorecmphoto, 25000);
when for first time user open this page its load last 10 comment
and everythings work fine and nice
but after 25-30 sec when new comment load with ajax
my feed.js not work for new comments?
what i must to do about this?
i put feed.js load every time when new comments load buts its bad cuz in 10 minute user have about 20 feed.js loaded !
can i do something else?
thank you