I am trying to send a image with AJAX.Though I keep on getting this error.
TypeError: 'append' called on an object that does not implement interface FormData.
This is my code:
$(document).ready(function(){
$('#post').on('submit', function(e){
e.preventDefault();
var data = new FormData(this);
$.ajax(
{
url: 'post_ajax/savePost',
type: 'POST',
dataType: false,
contentType: false,
pocessData: false,
data: data,
success: function (resultado) {
console.log(resultado)
}
}
).done(
function(json){
if(json.data){
console.log('Ajax correcto');
}else{
console.log('No se ha podido guardar el post');
}
}
).fail(
function(){
console.log('fallo en ajax');
}
);
});
});
And this is my html form:
<form id="post" enctype='multipart/form-data'>
<textarea id="texto" rows="4" cols="50" placeholder="¿Que esta pasando?"></textarea>
<input type="file" id="media"/>
<input type="submit" value="Submit"/>
</form>
Thanks you!!