I know this question might be a duplicate, but I have verified on each of their methods, and none seem to work.
Basically, my issue is that FormData(); isn't working for me, whether its creating an instance with FormData(myform) or just standalone formdata() with append, it's not doing anything.
Here is my code that I'm testing this on:
HTML
<form id="form">
<input type="hidden" name="id" id="id" value="1">
<input type="text" name="title" id="title">
<select name="category" id="category">
<option value="1">1</option>
</select>
<textarea name="desc" id="desc"></textarea>
<input type="file" name="cover" id="cover">
<div id="content">
Hello World
</div>
<input type="submit" name="submit" value="Submit">
</form>
<script src="js/jquery-2.2.1.js"></script>
<script src="js/now.js"></script>
JAVASCRIPT (now.js)
$('#form').on('submit', function(e){
e.preventDefault();
var myform = e.target;
var inputfile = document.querySelector('#cover');
var formData = new FormData(myform);
formData.append('file', inputfile.files[0]);
//formData.append('cover', $('input[type=file]')[0].files[0]);
var xhttp = new XMLHttpRequest();
xhttp.open('POST', 'data.txt', true);
xhttp.send(formData);
});
I would love some help guys.
PS. Console.log(formData) is a mess, nor do I see anything in it after looking through it afterwards either, and the network timeline runs, but no output.
Thanks guys,