serialise form jquery code example
Example 1: serialize and send form data jquery ajax
$.ajax({
type : 'POST',
url : 'url',
data : $('#form').serialize()
}
Example 2: jquery serialize
var datastring = $("#contactForm").serialize();
$.ajax({
type: "POST",
url: "your url.php",
data: datastring,
dataType: "json",
success: function(data) {
},
error: function() {
alert('error handling here');
}
});
Example 3: jquery form serialize object
$(function(){
$('form').on('submit', function(e){
e.preventDefault();
$(this).serializeObject().done(function(o){
if(window.console) console.log(o);
var j = JSON.stringify(o);
alert(j);
});
});
});