i have this jquery function:
function post_form(form_id) {
$( form_id ).submit(function(e) {
CheckRequired(e);
var postData = $(this).serializeArray();
var formURL = $(this).attr("action");
LoadModalBody('<h2 align="center">Loading...</h3><p align="center"><i class="fa fa-refresh fa-spin fa-5x"></i></p>', 'Loading');
$.ajax({
url : '/section' + formURL,
type: "POST",
data : postData,
success:function(data, textStatus, jqXHR) {
LoadModal('/section' + formURL, 'Mileage');
//$("body").html(data);
//data: return data from server
},
error: function(jqXHR, textStatus, errorThrown) {
//if fails
}
});
e.preventDefault(); //STOP default action
e.unbind(); //unbind. to stop multiple form submit.
});
}
i want to call it in a HTML form submit button
i know i can use onClick="post_form(); but how do i put the form id in the call, i think using this would be the submit button and not the form?