MySpace Developer Platform

A Place For Developers

Welcome Developers!

in

Welcome!

in

getting readyState of newFetchPersonAppDataRequest

Last post 07-14-2008 8:47 AM by TMadmin. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 07-10-2008 8:43 AM

    getting readyState of newFetchPersonAppDataRequest

    Hello everyone,

     

    I have noticed that in parts of my code, I attempt to retrieve app data and set it as a function return value.  This works fine, however, the data may not exactly be retrieved in time, and may return the previous value of the function, or "undefined" because the data hasn't been retrieved yet.

     Is there any way for me to wait on readyState for newFetchPersonAppDataRequest?

  • 07-11-2008 10:23 PM In reply to

    Re: getting readyState of newFetchPersonAppDataRequest

     Are you making this call asychronously by supplying a callback function?  That function shouldn't be called until the request has completed.  I have noticed, however, that appdata seems to be broken using the opensocial api.  I was only able to succesfully add/update data using the REST api.

  • 07-14-2008 8:47 AM In reply to

    Re: getting readyState of newFetchPersonAppDataRequest

    I realize why my function isn't returning the correct value, the callback isn't returning data yet, and I get the previous return value.  However, that's what I am trying to work around. I am looking for a way to get readyState or status on the callback to see whether it has completed yet or not.  I don't want to have to recreate the function everytime I call it.  In some places it's not possible, since I have several callbacks in a row that require the previous one to complete to compute values to call the next.

    Have I just reached the limitations of the current implementations of OpenSocial?

     

    Oh, and I have no problems updating data using the API.  I use the following function.

     

        function updateData(keyID, keyValue) {
            var statusField = document.getElementById('statusField');
            var req = opensocial.newDataRequest();
            req.add(req.newUpdatePersonAppDataRequest('VIEWER', keyID, escape(keyValue) ));
            req.send(updateSent);
        }

        function updateSent(response) {
              statusField.innerHTML = (response.hadError()) ? 'Error updating data... ' + response.getError() : 'Data Saved...<br>';
        }

Page 1 of 1 (3 items)