Hello to Everybody,

I m trying to fetch json remote data using following code -

<?xml version="1.0" encoding="UTF-8" ?>
<Module>
  <ModulePrefs title="Criticat json">
    <Require feature="opensocial-0.7"/>
  </ModulePrefs>
  <Content type="html">
  <![CDATA[
    <div id="content_div"></div>
    <script type="text/javascript">

    function makeJSONRequest() {
      var params = {};
      params[gadgets.io.RequestParameters.CONTENT_TYPE] =
gadgets.io.ContentType.JSON;
      // This URL returns a JSON-encoded string that represents a
JavaScript object
      var url = "http://example.com/meenu/jsonfetch.php";;
      gadgets.io.makeRequest(url, response, params);
    };

    function response(obj) {
      var jsondata = obj.data;
          var j = obj.text;
      alert("text" + j);
          alert("data" + jsondata);
          alert(obj.errors);
      var html = "<strong>Values: </strong><br /><br />";
      // Returned JS object can be processed as an associative array
      for (var key in jsondata) {
        var item = jsondata[key];
        html += key + ": ";
        html += item + "<br />";
      }
      document.getElementById('content_div').innerHTML = html;
     };
         gadgets.util.registerOnLoadHandler(makeJSONRequest);

     </script>
  ]]>
  </Content>
</Module>

& My server-side script is (in Php) -

<html>
<head>
</head>
<body>
<?php
   $arr = array("a"=>"Caucho","b"=>"Resin","c"=>"Quercus");
   $json = json_encode($arr);
   echo $json;
 ?>
</body>
</html>


But when I fetch obj.data,
I m getting-
null

& in obj.errors,I m getting-

failed to parse json

but in obj.text, I m getting the remote data................what is
the mistake I m doing in my code???????

Plz...........Solve the problem as early as possible.

Thanks in advance.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"OpenSocial Application Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/opensocial-api?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to