$('.submit_add').click(function(e){
e.preventDefault();
var data = $('#myform').serialize();
console.log(data); return false;
$.ajax({
url: '/ajax',
type: 'POST',
cache: false,
data: data,
dataType: 'json',
success: function(data) {
if (data.success == true ) {
window.location.href = '/';
} else {
alert('Error : There is something wrong.');
}
},
error: function(jqXHR, textStatus, err){
alert('text status '+textStatus+', err '+err);
}
})
});
Replace the above code by
$('.submit_add').click(function(e){
e.preventDefault();
var data = new FormData($("#myform")[0]);
console.log(data); return false;
$.ajax({
url: '/ajax',
type: 'POST',
cache: false,
data: data,
processData: false,contentType: false,
dataType: 'json',
success: function(data) {
if (data.success == true ) {
window.location.href = '/';
} else {
alert('Error : There is something wrong.');
}
},
error: function(jqXHR, textStatus, err){
alert('text status '+textStatus+', err '+err);
}
})
});
0 comments:
Post a Comment