728x90
function btn_deleteCategory() {
var deleteCategoryNoArray = [];
$("input[name=deleteCategory]:checked").each(function () {
deleteCategoryNoArray.push($(this).attr("value"));
});
console.log(deleteCategoryNoArray);
$.ajax({
type: "POST",
url: "/category/deleteCategoryName",
data: JSON.stringify(deleteCategoryNoArray),
contentType: "application/json; charset=utf-8",
dataType: "json",
})
.done(function (resp) {
alert("삭제가 완료되었습니다.");
location.href = "/";
})
.fail(function (error) {
alert(JSON.stringify(error));
});
}
11번째 라인에 'JSON.stringify'라는 구문
JSON.stringify는 JSON 객체를 String 객체로 변환 시켜주기 때문에 Controller에서 에러 없이 받아주게 된다.
https://dev-yujji.tistory.com/3
[Error] ajax 사용 중 'JSON parse error: ~'
ajax로 이것저것 해보던 중 에러를 만났다. JSON parse error: Unrecognized token 'param1': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false'); nested exception is com..
dev-yujji.tistory.com
728x90
'Spring (boot) 오류 해결' 카테고리의 다른 글
$ajax 공부 (url 주소 보낼땐 시큐리티 조심!//$ajax 통신법은 숙지!) (0) | 2022.02.13 |
---|---|
Lombok과 Json getter명명 규칙 (0) | 2022.02.12 |
cannot invoke because is null 페이지 처리 (0) | 2022.02.11 |
Required request parameter 'categoryName' for method parameter type String is not present (0) | 2022.02.10 |
Cannot make a static reference to the non-static method ~ (0) | 2022.02.09 |
댓글