Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Does the XMLHttpRequest automatically decoded my encoded url?

  • 3 replies
  • 1 has this problem
  • 50 views
  • Last reply by Shadow110

more options

So, today I made a request by using following code:

``` var oReq = new XMLHttpRequest(), url = '/blablabla/' + encodeURIComponent(btoa('%'));

oReq.open('POST', url);

oReq.send(); ```

Notice the value of variable `url` == '/blablabla/JQ%3D%3D'.

However, the URL which Firefox actually requesting is '/blablabla/JQ==' (Actually unescaped. I conformed it by watching my dev server panic).

I did the same test with Chrome, it does the right thing and queried the right URL (Which should be '/blablabla/JQ%3D%3D').

I want to know it's me or the Firefox caused this problem.

Thank you.

So, today I made a request by using following code: ``` var oReq = new XMLHttpRequest(), url = '/blablabla/' + encodeURIComponent(btoa('%')); oReq.open('POST', url); oReq.send(); ``` Notice the value of variable `url` == '/blablabla/JQ%3D%3D'. However, the URL which Firefox actually requesting is '/blablabla/JQ==' (Actually unescaped. I conformed it by watching my dev server panic). I did the same test with Chrome, it does the right thing and queried the right URL (Which should be '/blablabla/JQ%3D%3D'). I want to know it's me or the Firefox caused this problem. Thank you.

Chosen solution

Again I think you are asking in the wrong place. That is coding and this is General Support.

They do the coding here https://developer.mozilla.org they would know more than we do. I think this would just sit as not answered for a long time. Or if not there then sites that deal with that sort of coding. Like I do basic HTML5 Responsive and backwards and that's all I know and to put read made scripts in to my code. So ya, think in the wrong place.

Read this answer in context 👍 1

All Replies (3)

more options

I think possibly you should get a account on this site maybe...as this goes farther than most of help her do. Any way a place to start: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data

Please let us know if this solved your issue or if need further assistance.

more options

Thank you for respond.

I got around of the problem so I don't have to deal with it right now (I passed the data though POST body rather than query/URL so...)

To the topic, I don't think that document is related as the problem I had was the invalid URL not data.

So, simply put, I just want to know why my URL turned unescaped (Raw) during request even after I manually encodeURIComponent'ed it.

Modified by nickrio

more options

Chosen Solution

Again I think you are asking in the wrong place. That is coding and this is General Support.

They do the coding here https://developer.mozilla.org they would know more than we do. I think this would just sit as not answered for a long time. Or if not there then sites that deal with that sort of coding. Like I do basic HTML5 Responsive and backwards and that's all I know and to put read made scripts in to my code. So ya, think in the wrong place.