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.

3
  • 1
    try arr.join(); instead of arr.toLocaleString(); Commented Jul 13, 2017 at 10:45
  • and using arr.join(',') ,gives the same bug? Commented Jul 13, 2017 at 10:45
  • Are you sure the space is not being url encoded as %20? That is, aren't you seeing /1001,%200000/? Commented Jul 13, 2017 at 10:53

1 Answer 1

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"
Sign up to request clarification or add additional context in comments.

1 Comment

What is the problem though?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.