jquery - javascript comma doesn't encoded - Stack Overflow

i want to encode this text from2016, Odd Semester, Periode 1to2016%2C%20Odd%20Semester%2C%20Periode%201

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 ma.

it show like this

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

here my code

var Term = '2016, Odd Semester, Periode 1'
encodeURI(Term);

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 ma.

it show like this

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

here my code

var Term = '2016, Odd Semester, Periode 1'
encodeURI(Term);
Share Improve this question asked Nov 22, 2016 at 8:59 KentgiKentgi 3181 gold badge4 silver badges15 bronze badges 4
  • 4 use encodeURIComponent – Semi-Friends Commented Nov 22, 2016 at 9:00
  • 2 or use encodeURIComponent instead – Thum Choon Tat Commented Nov 22, 2016 at 9:00
  • 2 This function encodes special characters, except: , / ? : @ & = + $ # (Use encodeURIComponent() to encode these characters). – Kevin Kloet Commented Nov 22, 2016 at 9:01
  • related post: stackoverflow./q/18251399/6908282 – Gangula Commented Nov 12, 2024 at 18:20
Add a ment  | 

2 Answers 2

Reset to default 5

Use encodeURIComponent():

var foo = encodeURIComponent('2016, Odd Semester, Periode 1');
console.log(foo);

Use encodeURIComponent(). It should suffice.

The encodeURIComponent() function encodes special characters. In addition, it encodes the following characters:

, / ? : @ & = + $ #

var Term = '2016, Odd Semester, Periode 1'
encodeURIComponent(Term);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745197376a4616160.html

相关推荐

  • jquery - javascript comma doesn't encoded - Stack Overflow

    i want to encode this text from2016, Odd Semester, Periode 1to2016%2C%20Odd%20Semester%2C%20Periode%201

    9小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信