首页 > Web开发 > 详细

jquery常用

时间:2020-01-10 11:21:38      阅读:62      评论:0      收藏:0      [点我收藏+]

 

 

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);
}
    

 

jquery常用

原文:https://www.cnblogs.com/yaoyuan2/p/12175027.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!