AJAX使用记录

39次阅读

共计 582 个字符,预计需要花费 2 分钟才能阅读完成。

  • 传递数组
    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";
    }

正文完
 0