After getting some data using ajax & json i've got this function
if(data.length != 0) {
var arreglo = new Array();
$.each(data, function(index, data) {
if (jQuery.inArray(data.id, arreglo) == -1) {
arreglo.push(data.id);
$("#envivo").append("<li>Titulo: " + data.titulo + " Link: " + data.link + " Fuente: " + data.fuente + "</li>");
}
});
}
}
$(document).ready(function() {
var fecha = Math.round((new Date()).getTime() / 1000);
setInterval(function() {
$.ajax({
data: "fecha="+fecha,
type: "GET",
dataType: "json",
url: "data.php",
success: function(data){
restults(data);
}
});
}, 5000);
});
What i'm trying to do
- Check if any data it's retrieved from ajax
- Create an array to store data.id
- Loop inside the data from ajax
- Check if data.id it's in array created in [2]
- If id it's not in array, i save it into and apped some data
step 4 it's not working and part of the 5 (saving into array)
Any ideas?
Thanks in advance