I am trying to submit a file from a form using jQuery's ajax
method:
var ofile=document.getElementById('image').files[0];
var formdata = new FormData();
formdata.append("image",ofile);
$.ajax({
url:'elements/save_elements',
data:formdata,
type:'POST'
});
This results in the error TypeError: 'append' called on an object that does not implement interface FormData
.
What causes this error? It doesn't happen on the actual formdata.append
, but inside jQuery.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…