jquery image submit ajax code example
Example 1: jQuery AJAX form submit
$("#myFormID").submit(function(e) {
e.preventDefault();
var form = $(this);
var url = form.attr('action');
$.ajax({
type: "POST",
url: url,
data: form.serialize(),
success: function(data){
console.log(data);
}
});
});
Example 2: Upload image via ajax (jquery)
var form = new FormData();
form.append('varName','data');
$.ajax({
type:'POST',
url: $(this).attr('action'),
data:formData,
cache:false,
contentType: false,
processData: false,
success:function(data){
},
error: function(data){
}
});