How can I refresh a page after form submit?
This question already has an answer here:
Maybe you can use suggestion from this post: callback when form submitted using submit() method And replace alert("done") with location.reload();
For example:
<!-- 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/34714.html
上一篇: 我如何重定向另一个页面在PHP?
下一篇: 如何在表单提交后刷新页面?