There are two ways to send data to the server: get and post.
First, replace the html code in the body with
<pre class="brush:php;toolbar:false"> <button dojoType="Button" widgetId="helloButton">Hello World!</button><br> <br><br> 请输入名称: <input type="text" id="name">
<pre class="brush:php;toolbar:false"> function helloPressed()<br> {<br> dojo.io.bind({<br> url: 'response.txt',<br> handler: helloCallback<br> });<br> }<br>替换为:<br><pre class="brush:php;toolbar:false"> function helloPressed()<br> {<br> dojo.io.bind({<br> url: 'HelloWorldResponseGET.jsp',<br> handler: helloCallback,<br> content: {name: dojo.byId('name').value }<br> });<br> }
<%<BR> /*<BR> ' HelloWorldResponseGET.jsp<BR> ' --------<BR> '<BR> ' 打印name的值.<BR> '<BR> */<br><br> response.setContentType("text/plain");<BR>%>
Hello <%= request.getParameter("name") %> ,欢迎来到dojo世界!
<pre class="brush:php;toolbar:false"> <button dojoType="Button" widgetId="helloButton">Hello World!</button><br> <br><br> <form id="myForm" method="POST"><br> 请输入名称: <input type="text" name="name"><br> </form>
<pre class="brush:php;toolbar:false"> function helloPressed()<br> {<br> dojo.io.bind({<br> url: 'HelloWorldResponsePOST.jsp',<br> handler: helloCallback,<br> formNode: dojo.byId('myForm')<br> });<br><br> }
http://dojo.jot.com/WikiHome/Tutorials/HelloWorld