서버로 데이터를 보내는 방법은 get과 post 두 가지가 있습니다.
먼저 본문의 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> /*<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