javascript - How can I refresh a page after form submit? -
this question has answer here:
- how make redirect in php? 21 answers
hi can me on issue, please post whole code because noob in coding , allready lost many hours searching right answer. if want vote game see "spielbewertung" on page http://www.spielonline.ch/spiel.php/kogama-ostry.html page loads iframe nickolodeonspelheader.php page spiel.php after voting , url looks http://www.spielonline.ch/nickelodeonspelheader.php/kogama-ostry.html offcourse wrong should change data in database after input , come on original parent page game can played after voting. form code:
<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;"> <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> </table>
many in advance!
maybe can use suggestion post: callback when form submitted using submit() method , replace alert("done") location.reload();
for example:
<!-- import jquery in <head> tag --> <head> <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> </head> <body> <!-- 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 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>
Comments
Post a Comment