'Continuing submission (using second submit button) of a form after using Ajax to prevent default and do a calculation
I am using Ajax to prevent the default submission of a form and perform a calculation via a post route.
Once the ajax request has been completed, it maybe required to actually submit the form to the back end to continue the process via a second submit button, however this is also caught by the ajax request and it just completes the calculation again.
How can i bypass the ajax function via a secondary submit button and allow the next part of the process if required?
<script type="text/javascript">
$(document).ready(function() {
$('#calculator').on('submit',function(e){
$.ajax({
data : {
info1 : $('#searchBox').val(),
info2 : $('#description').val(),
info3 : $('#value').val(),
info4 : $('#length').val(),
info5 : $('#profile').val(),
},
type : 'POST',
url : '/calculate'
})
.done(function(data){
$('#result').show();
$('#result1').val(data.data1);
$('#result2').val(data.data2);
});
e.preventDefault();
});
});
</script>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
