------------參數傳遞的四種形式----- URL,超連結,js,form表單,------------form

來源:互聯網
上載者:User

------------參數傳遞的四種形式----- URL,超連結,js,form表單,------------form

什麼時候用GET,  查,刪,

什麼時候用POST,增,改  (特列:登陸用Post,因為不能讓使用者名稱和密碼顯示在URL上)

4種get傳參方式

<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>    <title></title>    <script type="text/javascript">        function Go() {            window.location.href="localhost:21811/Handler1.ashx?id=1&name='abc'"        }    </script></head><body>   <!--//參數傳遞的幾種形式-->    <!--第一種:直接在URL後面加參數:-->    localhost:21811/Handler1.ashx?id=1&name="abc"    <!--第二種:用超連結的方法傳遞參數:當點擊超連結的時候,首先會跳轉到localhost:21811/Handler1.ashx頁面,然後還會傳遞id 和name 兩個參數過去-->    <a href="localhost:21811/Handler1.ashx?id=1&name='abc'">超連結傳遞參數</a></body>    <!--第三種:通過js方法傳遞:使用者點擊這個button按鈕,觸發onClick事件,執行Go()方法,跳轉到localhost:21811/Handler1.ashx頁面,同時傳遞了id,和name兩個參數過去-->    <input type="button" onclick="Go()" value="通過js方法傳遞參數" />        <!--第四種:通過form表單傳遞-->    <form action="Handler1.ashx" method="get"><!--注意action裡面的串連不能帶參數的-->>        <input type="text" name="id" value="3" />        <input type="text" name="name" value="abc" />        <input type="submit" value="通過傳遞參數" />    </form></body></html>


著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.