最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

dojo 之基礎篇(三)之向服務器發(fā)送數(shù)據(jù)

 更新時間:2007年03月24日 00:00:00   作者:  
向服務器發(fā)送數(shù)據(jù)有get和post兩種.

首先,要將body中的html代碼替換為

  <button dojoType="Button" widgetId="helloButton">Hello World!</button>
<br>
請輸入名稱: <input type="text" id="name">
不輸入數(shù)據(jù),怎么提交數(shù)據(jù)呢.
  1. get
    我們只要將基礎篇(二)中的:
       function helloPressed()
    {
    dojo.io.bind({
    url: 'response.txt',
    handler: helloCallback
    });
    }
    替換為:
       function helloPressed()
    {
    dojo.io.bind({
    url: 'HelloWorldResponseGET.jsp',
    handler: helloCallback,
    content: {name: dojo.byId('name').value }
    });
    }
    即可.其中的url不用說也明白了吧.是相對路徑.也就是說在HelloWorld.html的當前目錄
    下應該有一個 HelloWorldResponseGET.jsp 文件. handler還是一樣,處理返回的數(shù)據(jù),
    如果有的話.
    content即為要發(fā)送的數(shù)據(jù). 其中名稱為name,name的值為你所輸入的值.

    這樣,我們可以在jsp中寫入簡單的代碼來獲得這個值,以下為jsp中的代碼

    <%
    /*
    ' HelloWorldResponseGET.jsp
    ' --------
    '
    ' 打印name的值.
    '
    */

    response.setContentType("text/plain");
    %>
    Hello <%= request.getParameter("name") %> ,歡迎來到dojo世界!
  2. Post
    這種方法即為在form表單提交提交數(shù)據(jù).

    相應的html代碼為:
      <button dojoType="Button" widgetId="helloButton">Hello World!</button>
    <br>
    <form id="myForm" method="POST">
    請輸入名稱: <input type="text" name="name">
    </form>
    dojo代碼為:
       function helloPressed()
    {
    dojo.io.bind({
    url: 'HelloWorldResponsePOST.jsp',
    handler: helloCallback,
    formNode: dojo.byId('myForm')
    });

    }
    這里將content屬性變?yōu)榱薴ormNode屬性.

    jsp的代碼不變.
到此,dojo的基礎篇告一段落. 這些內容來自dojo的官方網(wǎng)站. 更詳細的內容請參考官網(wǎng).
http://dojo.jot.com/WikiHome/Tutorials/HelloWorld

相關文章

最新評論

城市| 石泉县| SHOW| 五原县| 开封市| 晋江市| 杭州市| 吉隆县| 开平市| 鹤岗市| 班戈县| 五寨县| 鹿邑县| 保亭| 濮阳市| 甘孜县| 祁门县| 班玛县| 丽水市| 冷水江市| 全椒县| 崇州市| 武功县| 湖州市| 广南县| 桑日县| 拜泉县| 万安县| 望城县| 大荔县| 大厂| 孟连| 德惠市| 固镇县| 余姚市| 垣曲县| 永嘉县| 昌图县| 高邑县| 蓝田县| 清远市|