js

[JavaScript] encodeURI()

natrue 2022. 4. 5. 15:14
728x90

๋ฌธ์ž ์ฝ”๋“œ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋ฌธ์ž๋ฅผ ์ฝ”๋“œ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ๊ฒƒ์„ ๋ฌธ์ž ์ธ์ฝ”๋”ฉ(encoding)

์ฝ”๋“œ๋ฅผ ๋ฌธ์ž๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ๊ฒƒ์„ ๋ฌธ์ž ๋””์ฝ”๋”ฉ(decoding) 

 

encodeURI() : ์ฃผ์†Œ์—์„œ ์‚ฌ์šฉํ•˜๋Š”  :, ;, /, =, ?, & ๋“ฑ์„ ์ œ์™ธํ•˜๊ณ  ์ธ์ฝ”๋”ฉํ•˜๋Š” ํ•จ์ˆ˜

encodeURIComponent() :  ๋ชจ๋“  ๋ฌธ์ž๋ฅผ ์ธ์ฝ”๋”ฉํ•˜๋Š” ํ•จ์ˆ˜

decodeURI() :  encodeURI๋กœ ์ธ์ฝ”๋”ฉํ•œ ๋ฌธ์ž์—ด์„ ๋””์ฝ”๋”ฉํ•˜๋Š” ํ•จ์ˆ˜ 

decodeURIComponent() :  encodeURIComponent()๋กœ ์ธ์ฝ”๋”ฉํ•œ ๋ฌธ์ž์—ด์„ ๋””์ฝ”๋”ฉํ•˜๋Š” ํ•จ์ˆ˜

 

URI
https://truecode-95.tistory.com?true=์ฝ”๋”ฉ

encodeURI
https://truecode-95.tistory.com?true=%EC%BD%94%EB%94%A9

decodeURI
https://truecode-95.tistory.com?true=์ฝ”๋”ฉ

encodeURIComponent
https%3A%2F%2Ftruecode-95.tistory.com%3Ftrue%3D%EC%BD%94%EB%94%A9

decodeURIComponent
https://truecode-95.tistory.com?true=์ฝ”๋”ฉ

ajax ์‚ฌ์šฉ ์˜ˆ์‹œ 

$.ajax({
    url : encodeURI(geoserver + '/wfs?service=wfs&..............,
    type : "GET",
    dataType : "xml",
    async : false,
    success : function(xml){

 

 

 

 

 

 

 

 

 

 

์ถœ์ฒ˜ : https://www.codingfactory.net/10377