向服务器发送数据有get和post两种.
首先,要将body中的html代码替换为
<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> ' HelloWorldResponseGET.jsp<br> ' --------<br> '<br> ' 打印name的值.<br> '<br> */<br><br> response.setContentType("text/plain");<br>%>
Hello ,欢迎来到dojo世界!
<pre class="brush:php;toolbar:false"> <button dojotype="Button" widgetid="helloButton">Hello World!</button><br> <br><br>
<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