Dojo BASICS (III): sending data to the server _ dojo

Source: Internet
Author: User
Dojo BASICS (3) send data to the server and send data to the server using get and post.

First, replace the html code in the body

  Hello World!


Enter the name:
If you do not enter data, how can you submit the data.
  1. Get
    We only need:
    Function helloPressed ()
    {
    Dojo. io. bind ({
    Url: 'response.txt ',
    Handler: helloCallback
    });
    }
    Replace:
       function helloPressed()
    {
    dojo.io.bind({
    url: 'HelloWorldResponseGET.jsp',
    handler: helloCallback,
    content: {name: dojo.byId('name').value }
    });
    }
    Now, the URL in the example can be clearly described. The example is relative. The example is in the current directory of helloworld.html.
    There should be a HelloWorldResponseGET. jsp file. handler is still the same, processing the returned data,
    If yes.
    Content is the data to be sent. The name and name are the values you enter.

    In this way, we can write simple code in jsp to get this value. The following is the code in jsp.

    <%
    /*
    'Helloworldresponseget. jsp
    '--------
    '
    'Print the name value.
    '
    */

    Response. setContentType ("text/plain ");
    %>
    Hello <% = request. getParameter ("name") %>. Welcome to the dojo world!
  2. Post
    This method submits data in the form.

    The corresponding html code is:
      Hello World!


    The dojo code is:
       function helloPressed()
    {
    dojo.io.bind({
    url: 'HelloWorldResponsePOST.jsp',
    handler: helloCallback,
    formNode: dojo.byId('myForm')
    });

    }
    Here, the content attribute is changed to the formNode attribute.

    The jsp code remains unchanged.
Here, the basics of dojo have come to an end. These contents come from the official website of dojo. For more details, see the official website.
Http://dojo.jot.com/WikiHome/Tutorials/HelloWorld

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.