tunarob
tunarob

Reputation: 3058

Pass GET parameters in query-string

I need to do 2 things:

One of the parameters is redirect=URL_here. The problem is, that i must redirect to that page: /about/me?look=1&sort=asc Then, my URL looks like:

/mypage/?letter=S&redirect=/about/me?look=1&sort=asc

I know that this is wrong (contains two "?"). The question is, how to make that query string correctly?

Upvotes: 2

Views: 14501

Answers (3)

Harshit Tailor
Harshit Tailor

Reputation: 3281

Use Url encode

Like this

<script>
var c= 'd e'
var query= '?a=b&c='+encodeURIComponent(c);
var uri= 'http://www.example.com/script?query='+encodeURIComponent(query);
window.location= uri;
</script>

and use

 decodeURIComponent()

to decode

Upvotes: 0

vusan
vusan

Reputation: 5331

change = sign with your own like || on your link. In your case change link like this
/about/me?look||1&sort||asc

Then later you will change || with =

Upvotes: 0

Philip Tenn
Philip Tenn

Reputation: 6083

URL encode the query string values.

Upvotes: 2

Related Questions