Instead of using an HTML submit input, use a button instead with an
onclick handler.

<form action="#" name="myform">
  Tarefa:<input id="id_tarefa" type="text" value="" />
  <input type="button" value="add" name="name_s"
onclick="populateMyAppData()" />
</form>

Submitting a form sends a request to the URL specified in the form
element's 'action' attribute. Your form did not include this
attribute, hence the 400 error.

- Jason

On Jun 13, 7:54 pm, Vinicius <[EMAIL PROTECTED]> wrote:
> <?xml version="1.0" encoding="UTF-8" ?>
> <Module>
>   <ModulePrefs title="Write e Read Example" >
>     <Require feature="opensocial-0.7"/>
>   </ModulePrefs>
>   <Content type="html">
>   <![CDATA[
>
>   <script type="text/javascript">
>    gadgets.util.registerOnLoadHandler(populateMyAppData);
>    var htmlout = "";
>    var me = null;
>
>    /
> ************************************************************************
>     * Set user data
>     */
>    function populateMyAppData() {
>      var req = opensocial.newDataRequest();
>           var data1 = document.getElementById('id_tarefa').value;
>
>      htmlout += "Adicionado em AppField1 to " + data1 + "<br />";
>      req.add(req.newUpdatePersonAppDataRequest("VIEWER", "AppField1",
> data1)) + "<br />";
>      req.send(handlePopulateMyAppData, "update_appdata");
>         }
>
>    /
> ************************************************************************
>     * Handle responses from update person app data requests
>     */
>    function handlePopulateMyAppData(data) {
>      if (data.hadError()) {
>        htmlout += data.getError();
>      }
>      requestMyData();
>    }
>
>    /
> ************************************************************************
>     * Fetch app data
>     */
>    function requestMyData() {
>      var req = opensocial.newDataRequest();
>      var fields = [ "AppField1" ];
>
> req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER),
> "viewer");
>      req.add(req.newFetchPersonAppDataRequest("VIEWER", fields),
> "viewer_data");
>      req.send(handleRequestMyData);
>    }
>
>    /
> ************************************************************************
>     * Handle responses from app data requests
>     */
>    function handleRequestMyData(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
>      doSomethingWithMyData(mydata.getData());
>    }
>
>    /
> ************************************************************************
>    * Operate on user data
>    */
>    function doSomethingWithMyData(data) {
>      //Data is indexed by user id, and represents an object where
> keys
>      //correspond with the app data fields.
>      var mydata = data[me.getId()];
>      var div = document.getElementById('content_div');
>      htmlout += "My AppField1 data is: " + mydata["AppField1"] + "<br />";
>
>      div.innerHTML = htmlout;
>    }
>
>  </script>
>
> <h1>Tarefas do Dia</h1>
> <br>
> <hr>
> <form action="#" name="myform" onSubmit="populateMyAppData()">
> Tarefa:<input id="id_tarefa" type="text" value="" />
> <input type="submit" value="add" name="name_s" />
> </form>
> <hr>
>  <div id="content_div"></div>
>
>   ]]>
>   </Content>
> </Module>
>
> this return next error : Missing or malformed url parameter
> Error 400
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to