mardi 18 novembre 2014

jQuery Mobile load new data only


Vote count:

0




I'm working on this project for learning purposes. The tasks for now are very simple:



  1. Populate data from DB using $.getJSON.

  2. Check every 'n' seconds for new data and append it to the list.

  3. Notify user about new data changes.


Here is the example of where I got so far: ( JSBin ) All the issues will be visible when running the example.


Here is the JS code that i have:



$(document).bind('pageinit', function(){

var $myList = $( "#myList" );
var newItems = [];

function loadList(){
$.getJSON("http://ift.tt/1uOXJIa",function(data){

$.each(data, function( index, value ) {

newItems.push( "<li><a>" + value.airline + "</a></li>" );
if(data>newItems){
alert('New Entry');
data=newItems;
}
});
$myList.append( newItems.join( "" ) );
$myList.listview( "refresh" );
setTimeout(loadList,1000);
});
}
loadList();
});


Thanks for your help !



asked 15 secs ago







jQuery Mobile load new data only

Aucun commentaire:

Enregistrer un commentaire