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 ...

+ Reply to Thread
Results 1 to 3 of 3

how to send json data result from java servlet to javascript

  1. Default 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.

  2. Default 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

  3. Default 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/

+ Reply to Thread