我想在特定的时间段内使用jquery递归提交表单是否有办法这样做?
答案 0 :(得分:0)
您可以使用setInterval执行此操作,例如:
<script>
window.setInterval(sendForm, 3000); // 3000 millisecons, or 3 sec
function sendForm() {
//get the action-url of the form
var actionurl = document.getElementById("theForm").action;
//do your request an handle the results
$.ajax({
url: actionurl,
type: 'post',
dataType: 'json',
data: $("#theform").serialize(),
success: function(data) {
// You don't really want a window alert here, since
// it will block the execution. Only used for demo
// here you'd run the code after your form submits
// succesfully
window.alert("Submitted form");
}
});
}
</script>
<form id="theForm" method="POST" action="myReceiver.php">
<input type="text" value="demo value">
</form>
答案 1 :(得分:0)
您可以使用setTimeout javascript函数实现此目的。