• 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

  • 相关阅读:
    Luogu P5030 长脖子鹿放置(网络流)
    BZOJ3037 创世纪(基环树DP)
    LuoguP1240 诸侯安置
    LuoguP3128 [USACO15DEC]最大流Max Flow (树上差分)
    总结-一本通提高篇&算竞进阶记录
    LuoguP5022 旅行 (割点,基环树)
    $tsinsenA1067$
    $SCOJ4427 Miss Zhao's Graph$
    $Edmonds-Karp$[网络流]
    $AC自动机$
  • 原文地址:https://www.cnblogs.com/angelye/p/9812034.html
Copyright © 2020-2023  润新知