ajaxSetup()方法

來源:互聯網
上載者:User

標籤:des   style   blog   http   io   ar   color   使用   sp   

使用ajaxSetup()方法設定全域Ajax預設選項

使用ajaxSetup()方法可以設定Ajax請求的一些全域性選項值,設定完成後,後面的Ajax請求將不需要再添加這些選項值,它的調用格式為:

jQuery.ajaxSetup([options])$.ajaxSetup([options])

可選項options參數為一個對象,通過該對象設定Ajax請求時的全域選項值。

<body>    <div id="divtest">        <div class="title">            <span class="fl">奇偶性和是否大於0</span>             <span class="fr">                <input id="btnShow_1" type="button" value="驗證1" />                <input id="btnShow_2" type="button" value="驗證2" />            </span>        </div>        <ul>           <li>請求輸入一個數字                <input id="txtNumber" type="text" size="12" />           </li>        </ul>    </div>    <script type="text/javascript">        $(function () {            $.ajaxSetup({                dataType:"text",                sucess:function(data){                    $("ul").append("<li>你輸入的<b>  "                        + $("#txtNumber").val() + " </b>是<b> "                        + data + " </b></li>");                }            });            $("#btnShow_1").bind("click", function () {                $.ajax({                    data: { num: $("#txtNumber").val() },                    url: "http://www.imooc.com/data/check.php"                });            })            $("#btnShow_2").bind("click", function () {                $.ajax({                    data: { num: $("#txtNumber").val() },                    url: "http://www.imooc.com/data/check_f.php"                });            })        });    </script></body>

 

ajaxSetup()方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.