乐趣区

AJAX使用记录

  • 传递数组
    function A() {var articalList = new Array();
        $('input[name="check"]:checked').each(function () {articalList.push($(this).val());
        });
        
        alert(articalList);
        $.ajax({
            url: 'deleteArtical',
            type: 'post',
            contentType: "application/x-www-form-urlencoded",
            traditional: true,
            cache : false,
            data: {'articals': articalList},
            success: function (data) {alert("ok")
            },
            error: function () {alert("error")
            }
        })

    }
    @RequestMapping(value = "/bbs/deleteArtical", method= RequestMethod.POST)
    @ResponseBody
    public  String delete(@Param("articals[]") Integer[] articals) {for(int i = 0 ; i< articals.length ; i++){System.out.println(articals[i]);
        }
        return "ok";
    }

退出移动版