SetPreference does not always work?

I never had this problem before, but in my latest gadget it seems that setpreference does not always work! Has anyone else had this happen? Or know why! Thank you in advance

My code is straight forward so I don't know what I could be doing that would make it only work most of the time

function updateinfo(){

m_module.setPreference("feed", feedinput.value);

m_module.setPreference("num", numinput.value);

refreshContent();

[649 byte] By [incendy] at [2008-2-15]
# 1

Just a guess:

The amount of space for saving preferences is limited. You can store about approximately 1000 chars at this time.
Maybe you went over the limit?

MarijkeS at 2007-9-4 > top of Msdn Tech,Gadgets,Web Gadget Development...
# 2
That is good to know, but in this case it is a single number between 1 and 24. Very strange
incendy at 2007-9-4 > top of Msdn Tech,Gadgets,Web Gadget Development...
# 3
I, too, have had problems making multiple set calls in a row. I'm not sure if it's an asynchronous thing or what's going on. In my case, I was actually saving a lot of data (looping through ~50-100 small items and saving each). I'd see odd randomness like the first two values would save, then I'd miss two or three, and then four more would get saved, and I'd lose the next one, and so on. In my case, I solved it by saving a single delimited string of my values rather than saving each value individually and then parsing that string when I retrieved it later via get. While that's probably overkill for two values, it's something you might look into if you consistently have this problem.
ToddOs at 2007-9-4 > top of Msdn Tech,Gadgets,Web Gadget Development...
# 4
So instead of saving each preference just save one string seperating them and then pull the substrings in the getpreference method? That does sound like it will work, I will give it a try this evening! Thank you!!
incendy at 2007-9-4 > top of Msdn Tech,Gadgets,Web Gadget Development...
# 5
Remember that on Spaces, anything you set with setPreference() will not immediately be available to getPreference(). The page must be refreshed/reloaded before your calls to getPreference will work.
ShawnClark-MSFT at 2007-9-4 > top of Msdn Tech,Gadgets,Web Gadget Development...
# 6

Shawn Clark - MSFT wrote:
Remember that on Spaces, anything you set with setPreference() will not immediately be available to getPreference(). The page must be refreshed/reloaded before your calls to getPreference will work.

I've never really understood why that would be a problem. If you're able to save some information, that means you already have that available to you. Why would you try to re-load it with a getPreference() call? Call getPreference() during initialization to get any data that you may have previously saved, and then never call it again. There's simply no point. Manage your data within your gadget, call setPreference() to store it occasionally, and you're done.

ToddOs at 2007-9-4 > top of Msdn Tech,Gadgets,Web Gadget Development...
# 7
Yes, I am aware Shawn and that is not the problem. What happens is I would say 1 out of 3 times SetPreference fails to save the value when there is more than one setPreference variable being set. No errors, just the value is not set
incendy at 2007-9-4 > top of Msdn Tech,Gadgets,Web Gadget Development...