我必须更改文本框的值" autosaveoperation"每10秒钟有了它,我还必须在我的数据库中插入数据。
我尝试更改ajax success
操作的文本框值,但它没有更改。
<script>
jQuery(document).ready(function() {
var form = $("form");
var firstInput = $(":input:not(input[type=button],input[type=submit],button):visible:first", form);
jQuery(firstInput).after('<input name="autosave" type="hidden" value="new"/>')
jQuery(firstInput).after('<input id="autosaveoperation" name="autosaveoperation" type="text" value="stop"/>')
timePicker(10);
});
</script>
<script>
var s;
function timePicker(vr) {
// function for count down timer...
if (vr > 0)
{
vr--;
s = setTimeout('timePicker(' + vr + ')', 1000);
} else {
clearInterval(s);
jQuery("#autosaveoperation").val("start");
var str = $( "form" ).serialize();
$.ajax({
url: 'myfile.php',
type: "post",
data: str,
success: function(data){
s = setTimeout('timePicker(' + 10 + ')', 5000);
jQuery("#autosaveoperation").val("start");
return false;
},
beforeSend : function(){
},
});
}
}
</script>
&#13;
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>val demo</title>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<form accept-charset="UTF-8" action="myfile.php" method="POST">
<input type="text" value="click a button">
</form>
</body>
</html>
&#13;