Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'll give it a shot!</p> <p>This should get the LI's from the server every five seconds, and compare them against any existing comments, and if they are different, insert the new comments into the DOM and slide them down :</p> <pre><code>var comments = { get: function () { return $.ajax({ url : 'WebForm1.aspx', cache : false }); }, check: function (coll1, coll2, UL_ID) { var diff = []; $.each(coll2, function (_, li2) { var same = false; $.each(coll1, function (_, li1) { if ($(li1).text() == $(li2).text()) same = true; }); if (!same) diff.push(li2); }); this.output(diff, UL_ID); }, poll: function (UL_ID) { var self = this; self.get().done(function (data) { self.check($(UL_ID).find('li'), $('&lt;ul /&gt;').append(data).find('li'), UL_ID); }); }, output: function (elems, UL_ID) { $.each(elems, function (i, elem) { $(elem).hide().delay(i * 300).slideDown(350).appendTo($(UL_ID)); }); }, init: function (UL, interval) { var self = this; setInterval(function () { self.poll(UL); }, interval); this.poll(UL); } } $(document).ready(function () { comments.init('#Urunler', 5000); // ^^ starts plugin ^^ ID ^^ polling speed (5 seconds) }); </code></pre> <p>I highly recommend giving each comment an UUID in the database, and then use that to compare against to find new comments.<br> The code above now compares the content of the comment only, so if the exact same comment is posted twice, there could be issues. </p> <p>It seems like the only thing your database is outputting is the comment itself, there is no unique identifier, so that would require a change in the database structure were you'd add a row for UUID, which would be somewhat outside the scope of the question in my opinion.</p> <p>Here's a quick demonstration where the database has been substituted with localStorage</p> <p><a href="http://jsfiddle.net/6d4yC/4/" rel="nofollow"><strong>DEMONSTRATION</strong></a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload