i'm having problems uploading files using ajax post. have form several inputs (checkboxes, texts , files).
<form> <input name="name" type="text"> <input name="file" type="file" multiple> <input type="submit" id="submit"> </form>
i've got function retrieves data form:
function collectformdata(){ return { "event": $('#daevent').find('input:checked').next().text(), "likes": $('#dalike').find('input:checked').next().text(), "figure": $('#dafigure').find('input:checked').next().text(), "age": $('#daagetext').val(), "email": $('#daemail').val(), "extratext": $('#dafreetext').find('textarea').val(), "files": $('#dauploadphotos').find('input').get(0).files[0] }; }
and it's passed down to:
var datafrompage = collectformdata();
and here's post:
$.post('http://localhost:3000', datafrompage, function(data){ if (data == "done"){ alert('works'); } else { alert('damn, wrong'); } });
i error -
uncaught typeerror: illegal invocation
i've looked solution while now, couldn't find relevant answers. please me out? thanks!