[cgiapp] [OT] Anyone using JSON::XS to output to a web page?

Ron Savage ron at savage.net.au
Fri Oct 10 20:48:54 EDT 2008


Hi Folks

I'm using YUI (Yahoo User Interface) to display JSON data hard-coded in
the web page. But when I send the data from my CGI::App, it is not
displayed. Here's the core Javascript:

var json_data = new YAHOO.util.LocalDataSource
(
{results:
[
{name: "Ron Savage", email: "ron at savage.net.au", phone: "0"},
{name: "Zoe Savage", email: "zoe at savage.net.au", phone: "9"}
]
}
);

If I replace the above with this, where o.responseText is returned from
the server via Ajax:

json_data = new YAHOO.util.LocalDataSource(o.responseText);

the datasource displays "No records found.".

The Perl code on the server is:

return encode_json {results => [map { {email => $$_{'email'}, name =>
$$_{'name'}, phone => $$_{'phone'} } } @people]};

Any ideas?

-- 
Ron Savage
ron at savage.net.au
http://savage.net.au/index.html




More information about the cgiapp mailing list