js

[JavaScript] FormData() key value ํ™•์ธ ํ•˜๋Š” ๋ฐฉ๋ฒ•

natrue 2022. 2. 21. 13:38
728x90

FormData๋Š” ๋‹จ์ˆœํ•œ ๊ฐ์ฒด๊ฐ€ ์•„๋‹Œ XMLHttpRequest ์ „์†ก์„ ์œ„ํ•ด ์„ค๊ณ„๋œ ํŠน์ˆ˜ํ•œ ๊ฐ์ฒด ํ˜•ํƒœ๋ผ ๋ฌธ์žํ™” ํ•  ์ˆ˜ ์—†๋‹ค. console.log๋กœ ํ™•์ธ ๋ถˆ๊ฐ€๋Šฅ. ์•„๋ž˜์˜ ๋ฐฉ๋ฒ•์œผ๋กœ key valueํ™•์ธ ๊ฐ€๋Šฅ.

// FormData์˜ key ํ™•์ธ
for (var key of formData.keys()) {
     console.log(key);
}
            
// FormData์˜ value ํ™•์ธ
for (var value of formData.values()) {
     console.log(value);
}