I am trying to implement type = "button" in a form that, instead of processing information using the doPost method, processes the form using the doGet method (mainly to update the URL correctly), This specification makes it impossible to use type = "submit" or document.form1.submit () because I should not reference the doPost method.
I tried to solve the problem by first submitting the form and then redirecting the URL to the click button (and vice versa), but I find it difficult to get around the HttpServletRequest problems, since I need to use the HttpServletRequest from the form view in the doGet method.
Is there a way to use ajax to make the current form data in an HttpServletRequest with a click of a button? I am new to ajax and not sure about the correct syntax, etc.
Here is a short version of what I managed to compile in HTML:
<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>
source share