Created
October 5, 2011 07:43
-
-
Save FlorianX/1263878 to your computer and use it in GitHub Desktop.
der Request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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