DEV Community

Discussion on: I have a question about how to send data to websites

Collapse
 
rossangus profile image
Ross Angus

It occurs to me in hindsight that I was massively overthinking this - it's perfectly possible to pass data from one page to another via the querystring, and intercept that using JavaScript on the target site. Note, however, that this is not a secure means of passing data and should not be used for private information. Let's return to our form on web site A:

<form method="get" action="https://your-second-website-url-goes-here.test/">
   <label for="numberInput">Enter a number:</label><br>
   <input type="number" id="numberInput" name="numberInput"><br>
   <input type="submit" value="Submit">
</form>
Enter fullscreen mode Exit fullscreen mode

Note that the method has changed from post to get inside the form tag. This will convert the user input inside the form into a querystring, which will take the form:

https://your-second-website-url-goes-here.test/?numberInput=5

(assuming the user types 5 into the input field)

Getting the values from a querystring has multiple solutions (I have to admit, I've not used Proxy() before). But this will allow you to reflect user choices on one site on a completely different domain, albeit with a JavaScript dependency. And you don't need to touch server-side code.