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