jQuery, Ajax: Submit a form using jQuery/Ajax
$(function() {
//hang on event of form with id=myform
$("#myform").submit(function(e) {
//prevent Default functionality
e.preventDefault();
//get the action-url of the form
var actionurl = e.currentTarget.action;
//do your own request an handle the results
$.ajax({
url: actionurl,
type: 'post',
dataType: 'json',
data: $("#myform").serialize(),
beforeSend:function(){
launchpreloader();
},
complete:function(){
stopPreloader();
},
success: function(data) {
// ... do something with the data...
}
});
});
});
// via http://stackoverflow.com/questions/1200266/submit-a-form-using-jquery