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
Related Q & A:
- How to get a specific data after post method?Best solution by Stack Overflow
- How to send image to web server?Best solution by Stack Overflow
- Is there a web site you can post comments about a business that sells products via the web. Like the BBB?Best solution by Yahoo! Answers
- How can I add a HTML code to My Yahoo homepage?Best solution by Yahoo! Answers
- What is the HTML code to make your web more accurate?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.