ajax操作代码

$(document).ready(function(){

//初始化表格
initTable();

//新增
$("#addhfgl").on(
        "click",
        function() {
            $.dialog({
                type : 'iframe',
                url : ctx+"/jsp/sjccgl/hfrzgl/edit.jsp",
                title : '恢复日志管理',
                width : 850,
                height : 480,
                onshow : function() {
                },
                onclose : function() {
                    oTable.ajax.url(context + "/service/sjccgl/hfrzgl/queryHfgl").load();
                },
                oniframeload : function() {
                }
            });
        });


$("#returnBtn").on("click",function(){
    window.location.href=context+"/jsp/SJGL15.jsp";
});

$.ajax({
    type:"GET",
    url:ctx+"/service/demo/hfjd/findJdmc",
    success:function(data){
        for(var i in data){             
            $("#jd").append("<option value='"+data[i]+"'>"+data[i]+"</option>");
        }
    }
});



// 点击查询事件
$("#validate").on("click",function() {                        
    var mc = $("input[name='mc']").val();
    var jd = $("#JD").val();
    var kssj = $("#startDateTime").val();                                
    var jssj = $("#endDateTime").val();    
    var url= context+ "/service/sjccgl/hfrzgl/queryHfgl?mc="+ mc + "&jd="+ jd+ "&kssj="+ kssj+ "&jssj="+ jssj;
    oTable.ajax.url(url).load();
});

});

function initTable(){
    oTable = $("#sjList").dtable({
            //显示“正在加载”的图标                    
            "processing":true,
            "ajax":context + "/service/sjccgl/hfrzgl/queryHfgl",
            "serverSide":false,//服务器分页
            "bPaginate": true,//翻页功能
            "ordering":false,//排序按钮    
            "iDisplayLength" : 8,  //默认每页显示多少条记录  
            "bLengthChange": false, //改变每页显示数据数量  
            "bFilter": true, //过滤功能  
            "bSort":true, //排序功能  
            "bInfo": true,//页脚信息  
            "bAutoWidth": true,//自动宽度  
            "columns":[
                {"data":"mc"},
                {"data":"jd"},
                {"data":"hfcl"},
                {"data":"kssj"},
                {"data":"jssj"},
                {"data":"hs"},
                {"data":"sjl"},
                {"data":"zxr"},
                {"data":"id"},
            ],

            "columnDefs":[
                  {
                    "targets":8,
                    "data":"id",
                    "render":function(data,type,full){
                        return '<div class="btn-group pull-center"><button type="button" id="query" class="btn btn-xs ue-btn modify" onclick="look('+"'"+ full.id + "'"+')"  style="margin-left:5px;margin-bottom:3px"><span class="fa fa-cog"></span>查看</button>'
                                                            +'<span>&nbsp;&nbsp</span>'
                                                            +'<button type="button" id="edit" class="btn btn-xs ue-btn modify" onclick="forUpdate('+"'"+ full.id + "'"+')" style="margin-bottom:3px"><span class="fa fa-cog" ></span>编辑</button>'
                                                            +'<span>&nbsp;&nbsp</span>'
                                                            +'<button type="button" id="del" class="btn btn-xs ue-btn del" onclick="del11('+"'"+ full.id+ "'"+')"   style="margin-bottom:3px"><span class="fa fa-trash"></span>删除</button></div>'
                    }
                }
            ]

        });
return oTable;

}
//查看
function look(id){

$.dialog({
    type : 'iframe',
    url : context + "/service/sjccgl/hfrzgl/query?id="+ id,
    title : '恢复日志管理',
    width : 850,
    height : 450,

    onshow : function() {

    },
    onclose : function() {
        oTable.ajax.url(context + "/service/sjccgl/hfrzgl/queryHfgl").load();
    },
    oniframeload : function() {
    }
});

}

//删除信息
function del11(id){
//alert(“111”);
$.dialog({
type: ‘confirm’,
content: ‘确定删除?’,
ok: function () {
$.ajax({
url:context+”/service/sjccgl/hfrzgl/del?id=”+id,
type:”get”,
async:false,
success:function(){
oTable.ajax.url(context + “/service/sjccgl/hfrzgl/queryHfgl”).load();
},
error:function(data){
alert(data);
}
});
},
cancel: function () {}
});
}

//编写用户信息
function forUpdate(id) {

$.dialog({
    type : 'iframe',
    url : context + "/service/sjccgl/hfrzgl/edit?id="+ id,
    title : '恢复日志管理',
    width : 850,
    height : 480,        
    onshow : function() {

    },
    onclose : function() {
        oTable.ajax.url(context + "/service/sjccgl/hfrzgl/queryHfgl").load();
        },
    oniframeload : function() {
    }
});

}

打赏
  • 版权声明: 本博客所有文章除特别声明外,著作权归作者所有。转载请注明出处!
  • Copyrights © 2018-2020 丁振莹
  • 访问人数: | 浏览次数:

你的每一分支持,是我努力下去的最大的力量 ٩(๑❛ᴗ❛๑)۶

支付宝
微信