1var datastring = $("#contactForm").serialize();
2$.ajax({
3 type: "POST",
4 url: "your url.php",
5 data: datastring,
6 dataType: "json",
7 success: function(data) {
8 //var obj = jQuery.parseJSON(data); if the dataType is not specified as json uncomment this
9 // do what ever you want with the server response
10 },
11 error: function() {
12 alert('error handling here');
13 }
14});
1$.fn.serializeObject = function()
2{
3 var o = {};
4 var a = this.serializeArray();
5 $.each(a, function() {
6 if (o[this.name]) {
7 if (!o[this.name].push) {
8 o[this.name] = [o[this.name]];
9 }
10 o[this.name].push(this.value || '');
11 } else {
12 o[this.name] = this.value || '';
13 }
14 });
15 return o;
16};