I have a Ajax call I want to run on form submit to populate a value then I want to submit the form. The closest I can find to this is :
jQuery(document).ready(function () {
jQuery('#dealform').submit(function (e) {
e.preventDefault(); // Prevent default form submission
//Do the AJAX
jQuery.ajax({
type: "POST",
url: "/Admin/deals/dealload",
data: //the data
contentType: "application/json; charset=utf-8",
success: function (response) {
res = response;
jQuery('#post_data').val(res[0].message); // update the value
jQuery(this).unbind('submit').submit(); // this doesn't fire
}
});
});
});
How can I get the submit function to fire after preventing the event? or if because I am using .submit( with event prevent default is there another way to trigger the submit on ajax complete ?