How to replace% 2F in my requested ajax url?

I am using jQuery, my problem is ..

my url looks like this after an ajax request (using the hashchange function to enable history):

mysite.com/Content/#Disc%2Findex

I want it to look like this:

mysite.com/Content/#Disc/index

I noticed this line in js:

url = url.replace(/^.*#/, '');

Does this have anything to do with this? when I insert /between quotes that it works, but my content is not loading.

+3
source share
4 answers

Using:

unescape(url)

to convert% 2F to a /. The url.replace line you mentioned will remove the url before and including the # character, so:

http://mysite.com/Content/#Disc/index

will become:

Disc/index
+10
source

. %2F - HTTP- /, , , . , "".

+2

unescape is outdated, use

decodeURI(url)
decodeURIComponent(url)
+1
source

Try using urldecode()or rawurldecode()in an AJAX request.

0
source

All Articles