zoukankan      html  css  js  c++  java
  • jquery常用

    1、验证对象为空

    $.isEmptyObject(response.data)

    2、清空元素内容

    $('#treeview-selectable').empty();

    不要使用$(obj).html('');

    3、函数式

    //声明
    var treeViewManage = {
        init: function (_postUrl,_params,_realName) {
            var index = layer.load(0,{shade:false});//loading,加载中
            $.ajax({
                type: 'post',
                url: _postUrl,
                data: {"params": _params, "realName": _realName},
                success: function (response) {
                    if (response.code === '00') {
                        if($.isEmptyObject(response.data)) {//验证对象为空
                        } else {
                            treeViewManage.showTree(response.data);
                        }
                    } else {
                        layer.msg(response.msg, {icon: 0, time: 1000});
                    }
                    layer.close(index);//关闭加载
                },
                error: function (data) {
                    layer.msg(data.status + ":" + data.responseJSON.error, {icon: 0, time: 1000});
                    layer.close(index);
                }
            });
        },
        showTree: function (treedata) {
            if (data.length > 0) {
                    ...
            }
        };
    };
    //调用
    $(function () {
        treeViewManage.init(_url,_params,realName);
    }
        

     4. click 传参

    5. 简易ajax

    var lastId = $.ajax({url:"/doc/dir/nextId",async:false}).responseText;
  • 相关阅读:
    javaSE基础知识点
    java自定义注解
    java自定义线程池
    java写投票脚本自动化初探
    java线程安全初窥探
    锁的深入理解
    java守护线程与非守护线程
    java设计模式初探
    java内存模型初窥探
    uniapp中组件之间跳转遇到的问题
  • 原文地址:https://www.cnblogs.com/yaoyuan2/p/12175027.html
Copyright © 2011-2022 走看看