jquery load 方法回顯資料

來源:互聯網
上載者:User

標籤:data   http   char   tin   priority   public   cal   簡化   let   

使用jQuery對象.load()方法load() 方法的作用是可以通過 AJAX 請求從伺服器載入資料,並把返回的資料直接放置到指定的元素中。該方法使用起來非常簡單,大大簡化了ajax開發文法 : jQuery對象 . load(url, param ,callback);url 訪問伺服器位址 param 發送給伺服器參數 callback 當正常返回後 執行回呼函數注意:如果 param存在,以POST方式請求, 如果param 不存在,以GET方式請求樣本1、基本使用<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><!-- 引入jquery開發包 --><script type="text/javascript" src="js/jquery-1.12.3.js"></script><meta http-equiv="content-type" content="text/html; charset=UTF-8"><script type="text/javascript">    function test() {       //發送ajax請求,並將返回的響應結果直接賦給div        $("#mydiv").load("servlet/test1",{"str":"你很好","str2":"你很壞"});    }</script></head><body>    <button onclick="test();">點我</button>    <div id="mydiv">初始內容</div></body></html>
2、callback使用<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><!-- 引入jquery開發包 --><script type="text/javascript" src="js/jquery-1.12.3.js"></script><meta http-equiv="content-type" content="text/html; charset=UTF-8"><script type="text/javascript"> function test() { //發送ajax請求,並將返回的響應結果直接賦給div $("#mydiv").load("servlet/test1",{"str":"你很好","str2":"你很壞"},function(data){ //回呼函數裡面的內容 alert(data); }); }</script></head><body> <button onclick="test();">點我</button> <div id="mydiv">初始內容</div></body></html>注意:回呼函數在load填充完資料了之後執行

 

  項目代碼執行個體:

     

function loadLastInfo(detail){    $(‘#myform‘).form(‘load‘, { // 調用load方法把所選中的資料load到表單中,非常方便        customerCommisonType : detail.customerCommisonType,        customerCommison : detail.customerCommison,        otherPay : detail.otherPay,        otherPay01 : detail.otherPay01,        otherPay02 : detail.otherPay02,        otherPay03 : detail.otherPay03,        otherPay04 : detail.otherPay04,        otherPay05 : detail.otherPay05,        otherPay06 : detail.otherPay06,        otherPay07 : detail.otherPay07,        otherPay08 : detail.otherPay08,        otherPay09 : detail.otherPay09,        otherPay10 : detail.otherPay10,        otherPay11 : detail.otherPay11,        otherPay12 : detail.otherPay12,        isAudit : detail.audit,        isPriority : detail.isPriority,        remarks : detail.remarks    });}

 

jquery load 方法回顯資料

聯繫我們

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