ajax(20161110)

來源:互聯網
上載者:User

標籤:public   可擴充   title   www   傳回值   預設   括弧   code   head   

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><script src="jquery-3.1.1.min.js"></script><title>無標題文檔</title></head><body><!--ajax寫在JS裡面來用--><script type="text/javascript">    $.ajax({        url:"1110morningchuli.php", //處理頁面地址        data:{code:"n001"},//傳遞的資料,提交資料        type:"POST", //提交方式        dataType:"TEXT", //傳回值的類型(有三種)    TEXT  POST  XML:可延伸標記語言 (XML);可用在,1,資料的傳遞上使用,當作資料載體使用        success:function(data){ //回呼函數,括弧內的參數隨便命名,其實就是傳回值                alert(data);            },        error:function(){  //處理出錯執行                        }                });</script></body></html>

 

 

非同步處理

ajax調用的時候預設是非同步,效率高

非同步就是指在傳遞資料的時候不管對方是否接收,直接傳輸

同步就是指在傳遞資料的時候必須在對方接收後才能再傳遞下一個資料

對於ajax而言就是同時執行兩個線程

解決方案:
1,把ajax變成同步的
2,把加事件代碼放到ajax回呼函數裡面

 

ajax(20161110)

聯繫我們

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