Reputation: 12679
I need to redirect the following JS snippet, to http://localhost/homepage
at the end of $('form').submit();
How can I do it ?
<script>
//<![CDATA[
$(document).ready(function() {
$('#myModal .btn.btn-primary').click(function() {
$('#myModal').modal('hide');
$('form').submit();
});
});
//]]>
</script>
the html involved is here :
<div class='modal' id='myModal'>
<div class='modal-header'>
<div class='close'><a href="/">x</a></div>
<h3>Add Tags</h3>
</div>
<div class='modal-body'>
<form accept-charset="UTF-8" action="/tagging" data-remote="true" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /><input name="authenticity_token" type="hidden" value="7x2CSQ5spL32f1rjCJd5MdwYO6uZ+IwVsLEQ9ZB/Xcc=" /></div>
<input id="tags_string" name="tags_string" type="text" value="zoz" />
<input id="id" name="id" type="hidden" value="4f1c95e51d41c80ff20003f0" />
<div class='modal-footer'>
<!-- .btn.btn-primary= submit_tag "Add tag" -->
<a class='btn btn-primary'>
<input class='hidden' name='commit' type='submit' value='Add Tag'>
</a>
</div>
</form>
</div>
</div>
Upvotes: 0
Views: 137
Reputation: 4183
when you submit the form, it stops processing, it goes to the page where the form's 'action' directs (in your example, whatever page runs at /tagging) and that's it. If you want to do any redirection it'll have to do in the /tagging page after it does whatever it needs to do with the form fields
Upvotes: 1