I don't want to automatic scroll up the page when a form I submitted. I want to stay on the same position as when the form was submitted. How can I do that?
<script type="text/javascript">
var frm = $('#form');
frm.submit(function (ev) {
$.ajax({
type: frm.attr('method'),
url: frm.attr('action'),
data: frm.serialize(),
success: function (data) {
alert('ok');
}
});
ev.preventDefault();
});
<script>
function submitForm2()
{
document.getElementById('form').submit();
popsup();
}
</script>
<div onclick='submitForm2();'></div>
<form id='form' action='' method='post'>
<input name='test' value="ok">
</form>
I tried the solutions in the link; return false results in the page opening in a new window and in the new window the page autoscrolls to top after submit.
"#" or #! in action = form isn't submitted and page scrolls to top.
javascript:void(0); - form doesn't get submitted and page still scrolls to top