D
DougJrs
Good Afternoon All,
I am working on a project to write something that would allow others
to retrieve data about events that I am hosting. I was trying to
follow the same model that Google (http://code.google.com/apis/gdata/
json.html) and Yahoo (http://developer.yahoo.com/common/json.html)
have used with the JSON data being wrapped in a function call.
I have created a servlet that can have parameters passed to it and it
will return data like this:
myFunction([{title:"Event 1",url:"http:\/\/www.event.com",city:"City
Name",state:"New York"},{title:"Event 2",url:"http:\/\/
www.event.com",city:"City Name",state:"Kansas"},{title:"Event
3",url:"http:\/\/www.event.com",city:"City Name",state:"Florida"},
{title:"Event 4",url:"http:\/\/www.event.com",city:"City
Name",state:"Texas"}]);
When I place the following JavaScript on a page the result I get back
is: "[object Object][object Object][object Object][object Object]"
<script>
function myFunction(root) {
var html = root;
document.getElementById("agenda").innerHTML = html.join("");
}
</script>
<script src="http://localhost:8080/Web_Search_API/Jtest?
alt=4&callback=myFunction">
</script>
I tried to access the first item's details by altering the JavaScript
to this:
<script>
function myFunction(root) {
var html = "<h3>"
var data = root || [];
var entry = data[1];
var title = entry.title;
var url = entry.url;
html.push(title);
html.push(url);
html.push(root);
document.getElementById("agenda").innerHTML = html.join("");
}
</script>
When I made that change the page remained blank.
Can anyone point me to what I am doing wrong?
Thanks,
Doug
I am working on a project to write something that would allow others
to retrieve data about events that I am hosting. I was trying to
follow the same model that Google (http://code.google.com/apis/gdata/
json.html) and Yahoo (http://developer.yahoo.com/common/json.html)
have used with the JSON data being wrapped in a function call.
I have created a servlet that can have parameters passed to it and it
will return data like this:
myFunction([{title:"Event 1",url:"http:\/\/www.event.com",city:"City
Name",state:"New York"},{title:"Event 2",url:"http:\/\/
www.event.com",city:"City Name",state:"Kansas"},{title:"Event
3",url:"http:\/\/www.event.com",city:"City Name",state:"Florida"},
{title:"Event 4",url:"http:\/\/www.event.com",city:"City
Name",state:"Texas"}]);
When I place the following JavaScript on a page the result I get back
is: "[object Object][object Object][object Object][object Object]"
<script>
function myFunction(root) {
var html = root;
document.getElementById("agenda").innerHTML = html.join("");
}
</script>
<script src="http://localhost:8080/Web_Search_API/Jtest?
alt=4&callback=myFunction">
</script>
I tried to access the first item's details by altering the JavaScript
to this:
<script>
function myFunction(root) {
var html = "<h3>"
var data = root || [];
var entry = data[1];
var title = entry.title;
var url = entry.url;
html.push(title);
html.push(url);
html.push(root);
document.getElementById("agenda").innerHTML = html.join("");
}
</script>
When I made that change the page remained blank.
Can anyone point me to what I am doing wrong?
Thanks,
Doug