-
[JQuery] Ajax 배열 전송jquery 2021. 8. 24. 10:26
ajax 에서 데이터를 배열로 전송하고 싶을 때
traditional: true,
를 붙여준다.
$.ajax({ method: 'POST', url: '/', dataType: 'json', traditional: true, data: {idx: idx}, async: true, timeout: 3000, cache: false, headers: {'cache-control': 'no-cache', 'pragma': 'no-cache'}, success: function () { }, error: function (xhr, desc, err) { } });
그리고 컨트롤러에서 배열로 받으면 끝.
@RequestMapping(value = [("/")], method = [(RequestMethod.POST)]) @ResponseBody @Throws(Exception::class) fun list(idx: Array<String>): JSONObject { return service.list(idx) }
참고
https://javaoop.tistory.com/17
[jQuery] AJAX 배열전송(Array) Example
1. AJAX 배열(array) 전송시 주의사항 traditional : true 설정하기 Java Controller - getParameterValues로 받기 2. AJAX 사용법 간단 예제 코드 JSP 부분 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2..
javaoop.tistory.com