gpt4 book ai didi

php - 将值从 PHP 发送到 jQuery

转载 作者:行者123 更新时间:2023-12-01 04:01:16 26 4
gpt4 key购买 nike


我在 PHP 中有一个表单,我希望当我提交表单时,将输入值发布到 jQuery。
实际上,当单击提交按钮时,将“刷新时间”发布到 jQuery。

非常感谢您的帮助

<script>
setTimeout(function() {
window.location.reload();
}, $refresh-time);
</script>

<form method="POST">
<label>refresh number</label>
<input type="text" name="refresh-time">
<button type="submit">apply</button>
</form>

最佳答案

<script>
var refreshtime = <?= $_POST['refresh-time'] ?> || 10000;
setTimeout(function() {
window.location.reload();
}, refreshtime);
</script>

<form method="POST">
<label>refresh number</label>
<input type="text" name="refresh-time">
<button type="submit">apply</button>
</form>

我将 1000 设置为第一次使用的默认值。您必须从 $_POST 数组中读取才能访问表单提交值。然后使用标签 echo 在 javascript 代码上打印

关于php - 将值从 PHP 发送到 jQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42895979/

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