Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript comma doesn't encoded

i want to encode this text from

2016, Odd Semester, Periode 1

to

2016%2C%20Odd%20Semester%2C%20Periode%201

but i can't encode the comma.

it show like this

2016,%20Odd%20Semester,%20Periode%201

here my code

var Term = '2016, Odd Semester, Periode 1'
encodeURI(Term);
like image 229
Kentgi Avatar asked Nov 20 '25 08:11

Kentgi


1 Answers

Use encodeURIComponent():

var foo = encodeURIComponent('2016, Odd Semester, Periode 1');
console.log(foo);
like image 100
Rory McCrossan Avatar answered Nov 22 '25 21:11

Rory McCrossan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!