The basics of Dojo (iii) Send data to the server _dojo

Source: Internet
Author: User
Sending data to the server has two kinds of get and post.

First, you want to replace the HTML code in the body with the

  <button dojotype= "button" widgetid= "Hellobutton" >hello world!</button>
<br>
Please enter a name: <input type= "text" id= "name" >
Do not input data, how to submit data.
  1. Get
    We simply include the following:
     
     function hellopressed () 
    {
    Dojo.io.bind ({
    URL: ' Respo Nse.txt ',
    Handler:hellocallback
    });
    }
    is replaced by:
     function hellopressed () 
    {
    Dojo.io.bind ({
    URL: ' helloworldresponseg Et.jsp ',
    Handler:hellocallback,
    Content: {name:dojo.byId (' name '). Value}
    } br>}
    . One of the URLs is clear. is a relative path. That is, there should be a helloworldresponseget.jsp file under the helloworld.html current directory
    . Handler still the same, Process the returned data,
    if any.
    Content is the data that you want to send. The value named Name,name is the value you entered.

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

     <% 
    /*
    ' helloworldresponseget.jsp
    '------- -
    '
    ' prints the value of name.
    '
    */

    Response.setcontenttype ("Text/plain");
    %>
     Hello <%= request.getparameter ("name")%>, Welcome to Dojo World! 
  2. Post
    This method is to submit the submission data in the form form.

    The corresponding HTML code is:
      <button dojotype= "button" widgetid= "Hellobutton" >hello world!</button>
    <br>
    <form id= "MyForm" method= "POST" >
    Please enter a name: <input type= "text" name= "name" >
    </form>
    The Dojo code is:
       function hellopressed ()
    {
    Dojo.io.bind ({
    URL: ' helloworldresponsepost.jsp ',
    Handler:hellocallback,
    FormNode:dojo.byId (' MyForm ')
    });

    }
    This changes the content property to the Formnode property.

    The code for the JSP does not change.
To this, Dojo's basic article is over. The content comes from the official Dojo website. Please refer to the official website for more details.
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.