It works! Thanks Arne for your detailed explanation toward this problem. Now I know how to correctly deal with it. Thanks again.
Sean On Apr 24, 1:57 pm, "Arne Roomann-Kurrik" <[EMAIL PROTECTED]> wrote: > Hi Sean, > > This data is scoped per user ID and the key that you stored it under. Your > code will work if you change > > var testData = data.get("getData").getData(); > to > var testData = data.get("getData").getData()[viewer.getId()]["test"]; > > Otherwise, you're passing an object to unescapeString, which is an error. > Of course, there are times when you won't get a viewer object back, so for > robust code, you'll want to check that the viewer exists and returns a valid > ID number. > > Hope this helps, > ~Arne > > > > On Thu, Apr 24, 2008 at 9:03 AM, Sean <[EMAIL PROTECTED]> wrote: > > > Hi there, > > I was trying to store persistence data by the following codes. > > (reference: > >http://code.google.com/apis/opensocial/articles/persistence.html) > > However, instead of showing the user input, it turned out nothing. > > Firebug shows that there is a error occurred. > > > Error: H.replace is not a function > > [Break on this error] },unescapeString:function(H){return H.replace(/ > > &#([0-9]+);/g,B) > > > This line isn't part of my code so I have really no clue how to fix > > this one. > > Is this because of Orkut's constraint or there is something wrong with > > my code? > > Thank you in advance for your help. > > > <?xml version="1.0" encoding="UTF-8"?> > > <Module> > > <ModulePrefs title="hello world example"> > > <Require feature="opensocial-0.7"/> > > </ModulePrefs> > > > <Content type="html"><![CDATA[ > > <div id='main'> > > <div id='test'> </div> > > </div> > > <script> > > function setRequest() { > > var data = { > > html : "USER Input" > > } > > var req = opensocial.newDataRequest(); > > req.add(req.newUpdatePersonAppDataRequest( > > opensocial.DataRequest.PersonId.VIEWER, > > "test", > > gadgets.json.stringify(data)), > > "setData"); > > req.send(getRequest); > > } > > > function getRequest() { > > var req = opensocial.newDataRequest(); > > req.add(req.newFetchPersonRequest( > > opensocial.DataRequest.PersonId.VIEWER), > > "getViewer"); > > req.add(req.newFetchPersonAppDataRequest( > > opensocial.DataRequest.PersonId.VIEWER, > > "test"), > > "getData"); > > req.send(getResponse); > > } > > function getResponse(data) { > > var viewer = data.get("getViewer").getData(); > > var testData = data.get("getData").getData(); > > var unescapedTestData = gadgets.util.unescapeString(testData); > > var testObject = gadgets.json.parse(unescapedTestData); > > > document.getElementById("test").innerHTML = testObject.html; > > } > > </script> > > <script> > > gadgets.util.registerOnLoadHandler(setRequest); > > </script> > > ]]></Content> > > </Module> > > -- > OpenSocial IRC - irc://irc.freenode.net/opensocial --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Orkut Developer Forum" group. To post to this group, send email to opensocial-orkut@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/opensocial-orkut?hl=en -~----------~----~----~----~------~----~------~--~---