I am trying to implement a type="button" on a form that, instead of processing the information through the doPost method, processes the form using the doGet method (mostly for the purpose of being able to update the URL correctly). This specification is making it impossible to use type="submit" or document.form1.submit(), because I must not direct to the doPost method.
I have tried to work around the issue by first submitting the form, and then redirecting the URL on the button click (and vise versa), but I'm having difficulty getting around HttpServletRequest issues, as I need to use the HttpServletRequest from the form submission in the doGet method.
Is there any way to use ajax to make the current form data into an HttpServletRequest on the button click? I'm new to ajax and am unsure of the proper syntax, etc.
Here is the short version of what I've been able to gather in HTML so far:
<form id="form1" method="post" action="">
<div>
<input id="edit" type="button" name="edit" value="Edit" disabled="true" onClick="window.location.href='/new'"></input>
</div>
</form>
<script type="text/javascript">
$(document).ready(function() {
$("#edit").click(function() {
$.ajax({
type:
url: '/new',
data:
success:
error:
dataType:
});
});
});
</script>