how to send json data result from java servlet to javascript - Javascript
This is a discussion on how to send json data result from java servlet to javascript - Javascript ; I am new to YUI. I looked the datatable example and likes it a lot.
The example used PHP
----------------------javascript side----------------------
this.myDataSource = new YAHOO.util.DataSource("assets/php/
json_proxy.php?");
this.myDataSource.responseType =
YAHOO.util.DataSource.TYPE_JSON;
----------------------PHP side-----------------------------
require_once('JSON.php');
$json = new Services_JSON();
echo ($json->encode($returnValue)); // Instead ...
-
how to send json data result from java servlet to javascript
I am new to YUI. I looked the datatable example and likes it a lot.
The example used PHP
----------------------javascript side----------------------
this.myDataSource = new YAHOO.util.DataSource("assets/php/
json_proxy.php?");
this.myDataSource.responseType =
YAHOO.util.DataSource.TYPE_JSON;
----------------------PHP side-----------------------------
require_once('JSON.php');
$json = new Services_JSON();
echo ($json->encode($returnValue)); // Instead of json_encode
I wish I could do the same by using java servlet. Does any one have an
example or advice which can help me write some java code that can do
the same as the PHP code above does?
Thanks.
-
Re: how to send json data result from java servlet to javascript
On Mar 7, 6:18 pm, qingcai....@gmail.com wrote:
>[snip]
There is a java library that will help you to write JSON in java. I
use it and it works very well. Of course you don't have to go this
route, you can simply send your response as valid JSON text with a
content-type of text/x-json...
HTH
-
Re: how to send json data result from java servlet to javascript
On Mar 7, 8:29 pm, Tom Cole <tco...@gmail.com> wrote:
> On Mar 7, 6:18 pm, qingcai....@gmail.com wrote:
>
> >[snip]
>
> There is a java library that will help you to write JSON in java. I
> use it and it works very well. Of course you don't have to go this
> route, you can simply send your response as valid JSON text with a
> content-type of text/x-json...
>
> HTH
I could actually include the link, DUH...
http://www.json.org/java/