gpt4 book ai didi

PHP 不使用 ajax/jQuery 发送表单数据

转载 作者:行者123 更新时间:2023-11-30 05:50:43 25 4
gpt4 key购买 nike

如果不使用 HTML 表单,我将如何提交表单数据。

我只需要向 example.php 发送 1 个输入,并希望远离 ajax/jQuery。

也可以在不重定向/刷新页面的情况下在后台发送它。

下面的代码是我所得到的。我希望它发送 input_1 并且它的值为 value 1一旦页面加载到 example.php 而没有页面重定向。

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';

最佳答案

我认为 Jquery 在支持 Javascript 的设备上工作得很好。但是,您可以坚持使用传统的 xmlhttprequest。查看教程。

http://www.w3schools.com/ajax/ajax_xmlhttprequest_create.asp

关于PHP 不使用 ajax/jQuery 发送表单数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14973370/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com