I'm still new to JS and HTML5
So I have a URL that I store in a var
var Base_URL = "https://www.mywebsite.com/info?username";
Which is linked to a Database that has access to a username value that can contain spaces.
I parse this url into a function
function removeSpaceURL(url) {
var update = url.split(' ').join('%20');
return update;
}
It is not the best way I know but it works good enough for its purpose.
Where I'm stuck is that I want to return the update into a href reference so I can click it.
<p><a href="" onclick="removeSpaceURL(BASE_URL);return false;" >Survey</a></p>
<script>
var Base_URL = "https://www.mywebsite.com/info?username";
function removeSpaceURL(url) {
var update = url.split(' ').join('%20');
return update;}
</script>
When I try it on JSfiddle, I get the following error:
{"error": "Please use POST request"}
Base_URLbe a correctly-formed URL in the first place, which it isn't if there's a space in the username part of it.Base_URL, that's where this should be fixed.