Form submit with javascript works in Google Chrome only once
-
06-07-2019 - |
Question
I have simple form.
<form target="_blank" action="somescript.php" method="Post" id="simpleForm">
<input type="hidden" name="url" value="http://...">
<input type="hidden" name="code" value="wrxosf">
</form>
...and there are some anchor link
<a href="#" onclick="$('#simpleForm').submit();return false;">Do it!</a>
It works fine in FireFox or IE, but Google Chrome. Chrome does once, then link become unclickable.
Solution
Also had such problem.
The decision was to add something random to URL each time before submitting.
HTML:
<form action="go.php" method="post" target="_blank" id="go">
...
</form>
JavaScript (jQuery):
$('#go').attr('action','go.php?'+Math.random()*1000).submit();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow