Can anyone tell me how i could add an if else to the following please
Firstly hello all, new to the forum as just found out how fantastic jquery mobile is so getting a bit addicted
I am starting to put together an rss reader app but at the moment it gets the feed each time the button is pressed, what i would like to do is if there is an internet connection get the feed (And store it in local storage as well and if there is no internet go to the local storage to retreive the data
I have the live side up and running fine but need a bit of help getting the if else statement in the right place.
I think it needs to go in my refreshfeed() function but not sure how
I d like it to do
If internet available
get feed (run the code i ve got) and
call fanother function (Thats going to add the feed data to local storage)
else
Get feed from local memory
My function looks as follows
- function refreshFeed()
{
jQuery.getFeed({
url: "php/proxy.php?url="+url,
success: function(feed)
{
$("#page2 ul").append('<li data-role="divider" data-theme="b">'+feed.title+'</li>');
for(var i = 0; i < feed.items.length && i < 10; i++)
{
var item = feed.items[i];
$("#page2 ul").append('<hr><div id="myheader"><h2>'+item.title+'</h2></div><div id="mycontent">'+item.description+'</div>');
}
$('#page2 ul').listview('refresh');
$.mobile.pageLoading( true );
}
});
}
Many Thanks for your help, much appreciated
Gibbo