I have setup some automatic form submission code. Basically when a form is submitted javascript takes care of it, finding all inputs and such, and sending the data via ajax to the action attr of the form.
$j('body').delegate('form', 'submit', function(e) {
e.preventDefault();
if($j(this).prop('data-callback', true))
asf.forms.processForm($j(this).attr('name'), $j(this).attr('data-callback'));
else
asf.forms.processForm($j(this).attr('name'));
});
But i need to include callbacks. I need to make the code global so i cant code any specifics for each form. So i thought of adding an attribute with the callback function name like so:
<form action="" method="" data-callback="posts.addPost()">
The problem is I dont know how to fire that function inside javascript. Any ideas? I cant use onsubmit because i need access to all of the forms information which means doing this callback within the ajax response.
Thanks