I’m trying to use jquery to intercept a form submit, process that form submit using ajax, and then continue with the regular action= form submission. Is this even possible? Code below:
$(document).ready(function() {
$('form#myform').submit(function(e){
e.preventDefault();
dataString = $("#myform").serialize();
$.ajax({
type: "GET",
url: "ajax_process.php",
data: dataString,
success: function(returnvalue){ $('form#myform').submit(); }
});
});
});
What happens with this code is an infinite loop. Not sure how to get around it. I tried checking for e.isDefaultPrevented() but apparently that only triggers once per submit. Of course I could just curl the form info from within ajax_process.php but I’m wondering if there’s another way to do it from the javascript.