如何在表单提交后刷新页面?
这个问题在这里已经有了答案:
也许你可以使用这个帖子的建议:当使用submit()方法提交表单时回调并用location.reload()替换alert(“done”);
例如:
<!-- Import jQuery in your <head> tag -->
<head>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
</head>
<body>
<!-- your html source -->
<table style="display: inline-block;"><tr>
<td class="top" colspan="1" width="100%"><h2>Spielbewertung</h2></td></tr>
<tr><td width="50%" style="align:left;">
<!-- Add id attribute for form -->
<form id="submit-form" name="rating" action="" method="post">
<p style="font-family: tahoma; font-size: x-small;">
<b>Spiel bewerten:</b>
<select name="number">
<option value="">-</option>
<option value="3">3 = sehr schlecht</option>
<option value="4">4 = mangelhaft</option>
<option value="5">5 = langweilig</option>
<option value="6">6 = ausreichend</option>
<option value="7">7 = befriedigend</option>
<option value="8">8 = gut</option>
<option value="9">9 = sehr gut</option>
<option value="10">10 = hervorragend</option>
</select>
<input type="submit" name="vote" value="bewerten" style="cursor: pointer" />
</p>
</form>
</td></tr>
<script>
$form = $("#submit-form");
$form.on("submit",function()
{
alert("submitting..");
//do ajax
$.ajax({
url:<submit url>,
type:post,
success:function() {
location.reload();
}
});
});
$form.submit();
</script>
</body>
链接地址: http://www.djcxy.com/p/34713.html