2

I have an array like arr = ["1000","2000"].

I am converting this into comma separated value and then adding to my url.

Here I am converting to comma separated.

arr = arr.toLocaleString();

In my url, In chrome it is coming correctly but in IE it is coming % before value.

Chrome : /1001,2000/
    IE : /1001,%2000/

Url in IE is wrong. Anybody help me how to fix this.

Extra percentage is coming in url while checking in iE.

Pardeep Dhingra
  • 3,916
  • 7
  • 30
  • 56
shanky singh
  • 1,121
  • 2
  • 12
  • 24

1 Answers1

3

use .join() to join all elements of array into string ,and encode it, like:

var arr = ["1000","2000"],
    str = arr.join(","),
    encodedStr = encodeURIComponent(str); // "1000%2C2000"
Sudhir Bastakoti
  • 99,167
  • 15
  • 158
  • 162