zoukankan      html  css  js  c++  java
  • ajax将数组或list集合传到后台 的 【坑】

    代码如下

    function deleteChecked() {
                var orderNosList = new Array();
                var rows = $("#dataGrid").datagrid("getChecked");
                if (rows.length < 1) {
                    $.messager.confirm("提醒", "请选择招聘信息!");
                } else {
                    for (var i = 0; i < rows.length; i++) {
                        orderNosList[i] = rows[i].id;
                    }
                    var params = {
                        reserveOrderNoList : orderNosList
                    };
    
                    $.ajax({
                        url : '${ctx}/lf/ll_wb_job/deleteChecked',
                        data : JSON.stringify(params),
                        type : 'POST',
                        contentType : "application/json",
                        dataType : 'json',
                        success : function() {
                            console.log(data);
                        }
                    });
                }
            }

    前台页面、后台也不报错,就是获取不到

    修改如下

    function deleteChecked() {
        var rows = $("#dataGrid").datagrid("getChecked");
        var ids = [];
        if (rows.length < 1) {
            $.messager.confirm("提醒", "请选择招聘信息!");
        } else {
            for(var i=0; i<rows.length; i++){
                ids[i] = rows[i].id;
            }
            alert(ids)
                $.ajax({
                type: 'post',
                url: '${ctx}/lf/ll_wb_job/deleteChecked',
                data: {ids:ids},
                traditional: true,
                success: function (result) {
                    console.log(result)
                },
                error: function(data){
                    alert("操作异常");
                }
            }); 
        }
    }
    /**
        * 批量删除选中信息
        */
    @RequiresPermissions("lf:ll_wb_job:delete")
    @RequestMapping(value = "deleteChecked", method=RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> deleteChecked(HttpServletRequest request, HttpServletResponse response,Model model, Long[] ids) throws Exception {
        Map<String, Object> jsonMap = new HashMap<String, Object>(); 
        try{  
            boolean result = ll_wb_job_service.deleteChecked(ids);
            if (result) {
                jsonMap.put("success", true);
                jsonMap.put("msg", "操作成功");
            } else {
                jsonMap.put("success", false);
                jsonMap.put("msg", "操作失败");
            }
        }catch (Exception e) {
            log.error("系统异常",e);
            jsonMap.put("success", false);
            jsonMap.put("msg", "操作失败");
        }
        return jsonMap;
    }

    https://blog.csdn.net/qq_32786873/article/details/80280869
    https://blog.csdn.net/huaieli1/article/details/56678376/
    https://blog.csdn.net/zengguanlin/article/details/80067816?utm_source=blogxgwz0

  • 相关阅读:
    GUI的最终选择Tkinter模块初级篇
    JavaScript的进阶篇
    html标签详解
    docker使用自定义镜像zabbix服务
    Django之url定义和ORM框架的使用
    zabbix实现企业微信监控报警
    centos6 搭建nginx实现负载均衡
    mysql数据库进阶篇
    Linux运维之Ansible自动化运维管理工具
    php菜刀分析学习
  • 原文地址:https://www.cnblogs.com/angelye/p/9812034.html
Copyright © 2011-2022 走看看