[英]PHP send form data not using ajax/jQuery
How would I go about submitting form data without using HTML forms. 在不使用HTML表单的情况下如何提交表单数据。
I only need to send 1 input to example.php, and would like stay away from ajax/jQuery. 我只需要向example.php发送1个输入,并且想远离ajax / jQuery。
Also is it possible to send it in the background without redirecting/refreshing the page. 也可以在后台发送它而无需重定向/刷新页面。
The code below is as far as I have gotten. 下面的代码是据我所知。 I would like it to send
input_1
and it's value value 1
once the page loads to example.php
without the page redirecting. 我希望它在页面加载到
example.php
无需页面重定向的情况下发送input_1
及其value 1
的值。
theForm = document.createElement('form');
theForm.action = 'example.php';
theForm.method = 'post';
newInput1 = document.createElement('input');
newInput1.type = 'hidden';
newInput1.name = 'input_1';
newInput1.value = 'value 1';
I think Jquery works fine with the devices which supports Javascript. 我认为Jquery在支持Javascript的设备上可以正常工作。 However you can stick to the traditional xmlhttprequest.
但是,您可以坚持使用传统的xmlhttprequest。 check out the tutorial.
查看教程。
http://www.w3schools.com/ajax/ajax_xmlhttprequest_create.asp http://www.w3schools.com/ajax/ajax_xmlhttprequest_create.asp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.