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$(function(){
2 $('form').on('submit', function(e){
3 e.preventDefault();
4 $(this).serializeObject().done(function(o){
5 if(window.console) console.log(o);
6 var j = JSON.stringify(o);
7 alert(j);
8 //window.open("data:image/png;base64," + o.userfile.data);
9 });
10 });
11});
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};