Question: I want to submit a POST request while passing a url among other parameters.
I have the following script but it is not working.

```
var params = "param1="+param1_value+"&url="+url_value;

var xhr = new XMLHttpRequest();
xhr.open("POST", action_url, true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function(){
  if(xhr.readyState == 4 && xhr.status == 200){
    console.log("Done");
  }
}
xhr.send(params);

```

Assuming that the `url_value` is something like this:

```
https://www.domain.com/blah?param=&amp;email=domain%40email%2Ecom&amp;blah=1234

```

what would be wrong with this script?

Answer: 
Take a look at this question/answer - [Should I URL-encode POST data?](https://stackoverflow.com/questions/6603928/should-i-url-encode-post-data)

Your sample value for `url_value` is using the [HTML Entity Code](http://dev.w3.org/html5/html-author/charref). Because of the `&` symbol in the value, it is being sent as multiple values. You probably need to URL encode it so it looks like this

`https%3A%2F%2Fwww.domain.com%2Fblah%3Fparam%3D%26email%3Ddomain%40email.com%26blah%3D1234`
You may have a problem when trying to access another domain/website. The receiving side must have the `Access-Control-Allow-Origin` header in its return message.

You can probably find your solution in [this answer](https://stackoverflow.com/a/10636765/1369528).