Skip to content

Instantly share code, notes, and snippets.

@FlorianX
Created October 5, 2011 07:43
Show Gist options
  • Save FlorianX/1263878 to your computer and use it in GitHub Desktop.
Save FlorianX/1263878 to your computer and use it in GitHub Desktop.
der Request
// check if there is data from the localStorage and
// whether the data must be fetched live
if(localNewsJSON && !live){
// call renderNews with the data from the localStorage
renderNews(JSON.parse(localNewsJSON));
}else{
// fetch the news from the REST interface of the news plattform
$.ajax({
url: "http://spirit.fh-schmalkalden.de/news",
dataType: 'json',
success: function (data){
// save the data to the localStorage
localStorage.setItem('SpiritNews', JSON.stringify(data));
// call renderNews with the fetched data
renderNews(data);
},
error: function(jqXHR, textStatus, errorThrown){
// hide the loading animation
$.mobile.hidePageLoadingMsg();
alert("Konnte keine Verbindung zum Server herstellen!");
}});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment