How to add Jquery variable


I'm pretty new with Jquery so apologies if I don't know the correct naming conventions..

I've created a variable stored in localStorage but I can't seem to add it into an exisiting function.
I'm trying to add:
var RSSone = localStorage.getItem('RSSone');

Open in new window

Where the value of the item is an RSS feed such as

I'd like to add the RSS feed into the code below...

var newsfeed=new gfeedfetcher("rssfeeds", "rssfeedsclass", "_new")
newsfeed.addFeed("Ormiston School News", "");
newsfeed.addFeed("BBC Tech Feed",  "");
newsfeed.displayoptions("label datetime snippet");
newsfeed.filterfeed(10, "date");

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gurvinder Pal SinghCommented:
when you do,
var RSSone = localStorage.getItem('RSSone');

are you able to get the value of 'RSSone' in your application?
If yes, then why are you not able to use it?

Let me know if my understanding of your question is correct
grahammilesAuthor Commented:
I'm able to get RSSOne stored in localStorage but I can't seem to add it to the jquery script above. It just does nothing or kills it.

I thought something like this would work:

newsfeed.addFeed("RSS Feed One", $RSSone );

the code called for addFeed is:
gfeedfetcher.prototype.addFeed=function(label, url){

Open in new window

Gurvinder Pal SinghCommented:
did you tried this also
newsfeed.addFeed("RSS Feed One", RSSone );

why was the dollar sign required there?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

grahammilesAuthor Commented:
I feel stupid now! I set it up as a global variable and that works fine - I thought the dollar sign declared a variable and had tried both...

It works as a global variable but still can't call it from local storage.
grahammilesAuthor Commented:
Almost there I hope...

If I set up localStorage as below, it stores the variable but comes up as 'undefined' when it tries to load the RSS feeds...

  localStorage.setItem('RSSone', '""'); //saves to the database, key/value
  var feedOne = localStorage.getItem("RSSone");

Open in new window

Gurvinder Pal SinghCommented:
i think first line is asynchronous one.

there should be some delay in first and second line
grahammilesAuthor Commented:
I'm not sure how I would create a delay there? The second line is not actually needed, just there to help see if its working.
Gurvinder Pal SinghCommented:
are you able to check in the local storage that the value is setting correctly or not?
grahammilesAuthor Commented:
Yep. It writes to the page and I can see its there in Firebug.

I think just talking through it has helped me to solve it.

newsfeed.addFeed("Local Feed Test", localStorage.getItem("RSSone"));

Open in new window

Thanks for holding my hand!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.