Hello, there is a website, it is published.
The principle is very similar to "In touch": when scrolling to the bottom of the page need to be loaded news.
Every piece of news the user can write a comment, put like, seen yet
Now it's all done very crooked.
The basic requirement is ajax that all these actions are performed without reloading the page.
Now the huskies made thus:
Using Php generated id of elements. Over the counter.
1. Like1 button that sends the value of the hidden field id_pub1 in the ajax handler.
2. Like2 button, it sends the value of the hidden field id_pub2 in the ajax handler.
And so to all records.
In JS it is handled like this:
$(document).ready(function () {
var i = 0;
while(i < 1000){
(function(i){
$("#like"+i).click(function(){funcLike(i)});
$("#dislaik"+i).click(function(){funcDisLike(i)});
})(i++);
}
});
Respectively in the functions is already checked took it like/disli or set, is sent to the handler, etc.
1 question: is it at all organized? It confuses the counter in js to 1000, because, theoretically, you can download and more publications. And indeed the generation of id-shnik in php, feel in the end will lead to some confusion.
The next problem is that if I dogrusu using ajax publishing, the above js code does not handle downloaded id. The problem is common, but the solutions I found.
2 question: Again, originally is it right at all? If Yes, then how to get around this problem?
Well, anyway, the main purpose of my question is to know how would You approach implementing this type of issue?
Thanks in advance for your answers.