zoukankan      html  css  js  c++  java
  • jquery load 方法回显数据

    使用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
        });
    }
  • 相关阅读:
    Xamarin.Forms移动开发系列1:介绍和安装
    网络协议 1
    07 MySQL之索引原理
    06 Navicat安装及简单使用
    05 Mysql之多表查询
    04 Mysql之单表查询
    03 Mysql数据库之(行记录)详细操作
    02 Mysql之库表简易操作
    01 Mysql数据库初识
    07 Python之协程
  • 原文地址:https://www.cnblogs.com/mr-wuxiansheng/p/6415766.html
Copyright © 2011-2022 走看看