I am trying to implement the template tutorial.I have the following
the JSON object :
[{
"title" : "Love song #15",
"url" : "http://allmusic.com/johndoe/greatesthits/lovesong15.mp3",
"artist" : "John Doe",
"album" : "Greatest Hits",
"albumThumbnail" : "http://allmusic.com/johndoe/greatesthits.jpg"
},
{
"title" : "Love song #16",
"url" : "http://allmusic.com/janedoe/greatesthits/
lovesong16.mp3",
"artist" : "Jane Doe",
"album" : "Best Of",
"albumThumbnail": "http://allmusic.com/janedoe/bestof.jpg"
}]
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="My Friends">
<Require feature="opensocial-0.7"/>
<Optional feature="content-rewrite">
<Param name="include-tags"></Param>
</Optional>
</ModulePrefs>
<Content type="html">
<![CDATA[
<!-- Load the bundled code for OpenSocial Templates -->
<script type="text/javascript"
src="http://ostemplates-demo.appspot.com/ostemplates.js">
</script>
<script type="text/os-template" >
<ul>
<li repeat="songs">
<a href="${url}">
<img src="${albumThumbnail}"/>
${title} BY ${artist} FROM ALBUM ${album}
</a>
</li>
</ul>
</script>
<script type="text/javascript">
function init() {
makeJSONRequest();
}
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://www.comparos.nl/hyves/song4.txt";
gadgets.io.makeRequest(url, response, params);
};
function response(obj) {
var songs = obj.data;
var html = "";
os.Container.processDocument(songs);
};
gadgets.util.registerOnLoadHandler(init);
</script>
]]>
</Content>
</Module>
Firebug shows no errors, the get response works, it just doesn't load
the two objects.The single object template worked fine. Maybe i am
representing the JSON-object in the wrong format.Thanks in advance for
your help.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---