jquery on ajax submit code example
Example 1: jquery ajax form submission
$(function() {
$('form.my_form').submit(function(event) {
event.preventDefault();
var form = $(this);
$.ajax({
type: form.attr('method'),
url: form.attr('action'),
data: form.serialize()
}).done(function(data) {
}).fail(function(data) {
});
});
});
Example 2: jquery ajax form submit example
$.ajax({
type: "POST",
url: "upload.php",
data: { name:name, mobile:mobile, address:address, city:city },
dataType: "json",
success: function(result){
}
});