I am trying to fire a function using Jquery when the form submit button is clicked, but the function needs to fire BEFORE the form is actually submitted.
I am trying
Based on Wakas Bukhary answer, you could make it async by puting the last line in the response scope.
$('#myform').submit(function(event) {
event.preventDefault(); //this will prevent the default submit
var _this = $(this); //store form so it can be accessed later
$.ajax('GET', 'url').then(function(resp) {
// your code here
_this.unbind('submit').submit(); // continue the submit unbind preventDefault
})
}