Your requestData and handleRequestData functions look OK but your AddData function looks off.
Since you didn't provide the rest of your application, I have to assume that "input_comm" is the ID of an HTML text input -- thus, taking the value of the input, which is fine. The key that you're using won't work, however, since it's always undefined. This value needs to be a string (e.g. 'thefield' as you use in requestData). Once you make this fix, your sample should be much closer to working. In the future, please provide a better explanation of the problem. "It's not working" is not as helpful as reporting any errors or incorrect output you see, etc. Thanks. - Jason On Jun 23, 10:37 pm, Vinicius <[EMAIL PROTECTED]> wrote: > what is wrong in the code?????? not running this ... I tried this > code ... use array pra register several keys dynamically and their > values , help me plis !!! > > <script type="text/javascript"> > gadgets.util.registerOnLoadHandler(requestData); > > var htmlout = ""; > var me = null; > > function AddData() { > var req = opensocial.newDataRequest(); > var palavras = document.getElementById("input_comm").value; > var thefield = []; > > req.add(req.newUpdatePersonAppDataRequest("VIEWER", > thefield[thefield.length], palavras)); > req.send(requestData); > } > > function requestData() { > var req = opensocial.newDataRequest(); > var fields = [ "thefield" ]; > > req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER), > "viewer"); > req.add(req.newFetchPersonAppDataRequest("VIEWER", fields), > "viewer_data"); > req.send(handleRequestData); > } > > function handleRequestData(data) { > var mydata = data.get("viewer_data"); > var viewer = data.get("viewer"); > me = viewer.getData(); > > if (mydata.hadError()) { > htmlout += data.getError(); > return; > } > // Do something with the returned data - note the getData call > doSomethingWithData(mydata.getData()); > } > > function doSomethingWithData(data) { > //Data is indexed by user id, and represents an object where > keys > //correspond with the app data fields. > var mydata = data[me.getId()]["thefield"]; > > document.getElementById('content_div').innerHTML += > mydata[mydata.length] + "<br />";} > > </script> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---