我想重复发送 username 和 password 的值到 php
脚本。我该怎么做呢 ?就像将值发送到 ActionScript 一样,我们使用 submit
按钮,但我如何才能将值自动发送到脚本并且持续不断?
<form method="post" action="processor.php">
<input type="username" value="suhail" />
<input type="password" value="secret_code" />
<input type="submit" />
</form>
最佳答案
使用 jQuery form plugin您可以执行以下操作:
setInterval(function() {
$('form').ajaxSubmit();
}, 1000);
另一种解决方案是将表单定位到 iframe,这样如果您提交表单,它就不会重新加载页面:
HTML:
<form id="myform" method="post" action="processor.php" target="frm">
<input type="username" value="suhail" />
<input type="password" value="secret_code" />
<input type="submit" />
</form>
<iframe name="frm" id="frm"></iframe>
JS:
var form = document.getElementById('myform');
setInterval(function() {
form.submit();
}, 1000);
关于javascript - 持续向 ActionScript 发送值。怎么做?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19497107/