Hola, estoy elaborando un sitio, donde se actualiza constantemente un RSS, se añaden cada 30 segundos 2 o 3 elementos nuevos con JQuery, pero cada vez que avanza el tiempo se hace la pagina demasiado grande, lo que quiero hacer es limitar elementos por ejemplo a 15 y si se añaden 2 elementos, se borren los últimos osea 14 y 15.
Este es mi codigo .JS:
Código:
function loadSearch()
{
//show message when the feed is loading
$("#update-alert").text("Loading new results...");
//ajax request to get the results from search.php
$.ajax({
url : "search.php",
success : function(results){
//counter to count new results
var counter = 0;
//find each 'div' with class 'result' from the response and loop through them
$(results).find("div.result").each(function(i){
//get the id of the div
var div_id = $(this).attr("id");
//check if any div with the same id already exists
if( $("#twitter-update div#" + div_id).length == 0 )
{
//if doesn't exist then prepend this div
$("#twitter-update").prepend(this);
//increase the counter
counter++;
}
});
//show the number of new results
if(counter == 0)
$("#update-alert").text("no new result");
else if(counter == 1)
$("#update-alert").text("1 new result");
else
$("#update-alert").text(counter + " new results");
}
});
}
$(document).ready(function(){
loadSearch();
setInterval("loadSearch()",30000);
});
He escuchado que con la funcion .remove(); pero estoy demasiado verde en jquery.
Alguna idea, como podría hacerlo?
Saludos gracias por adelantado.