How to send data from device to remote server?

What html code can send data to web server directly using "post" method except a form?

  • I'm a beginner in HTML. I need to make a button to send predefined data to server, the button is just for confirmation. I'm using the following code <form method="POST" action="."> <input type="hidden" name="confirm" value="1" /> <input type="submit" value="OK" /> </form> but I think it can be shorter, without JavaScript. I've tried: <form method="POST" action="."> <input type="submit" name="confirm" value="1" /> </form> but the word "1" on the button may confuse users.

  • Answer:

    It looks like your solution already does what you want, but it does have the downside of taking the user to another page when they submit the form. Here's a somewhat hacky but Javascript-free fix: Keep doing what you're doing, but submit the form to a hidden iframe instead. <!-- Your new HTML. Note the target="sneaky" on the form and the matching name="sneaky" on the iframe. --> <iframe src="doesnt-matter" class="hidden" name="sneaky"></iframe> <form method="post" action="." target="sneaky"> <input type="hidden" name="confirm" value="1" /> <input type="submit" value="OK" /> </form> /* And some CSS to hide the iframe */ .hidden { display:none; } Just like using target on a link to make it open in a certain window, you can use it on a form to control where the submission results show up. A hidden iframe is a valid target too, so the data will go where you send it and the results will just "appear" in a piece of the UI that your users never see.

Bulat Bochkariov at Quora Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.