how to send json data result from java servlet to javascript

Discussion in 'Javascript' started by qingcai.wei@gmail.com, Mar 7, 2008.

  1. Guest

    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.
    , Mar 7, 2008
    #1
    1. Advertising

  2. Tom Cole Guest

    On Mar 7, 6:18 pm, 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
    Tom Cole, Mar 8, 2008
    #2
    1. Advertising

  3. Tom Cole Guest

    On Mar 7, 8:29 pm, Tom Cole <> wrote:
    > On Mar 7, 6:18 pm, 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/
    Tom Cole, Mar 8, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. circuit_breaker
    Replies:
    2
    Views:
    1,993
    Jack Jia
    Apr 4, 2004
  2. =?utf-8?B?6L65IOaxnw==?=

    [Servlet] how to send a stream to servlet doPost

    =?utf-8?B?6L65IOaxnw==?=, Sep 14, 2007, in forum: Java
    Replies:
    3
    Views:
    640
    GArlington
    Sep 14, 2007
  3. Michael Tan
    Replies:
    32
    Views:
    955
    Ara.T.Howard
    Jul 21, 2005
  4. Florian Frank
    Replies:
    0
    Views:
    237
    Florian Frank
    Jun 30, 2009
  5. Replies:
    0
    Views:
    117
Loading...

Share This Page