Use form data constructor

This commit is contained in:
mmcwilliams 2017-11-21 16:52:59 -05:00
parent 550dad4c91
commit 58d173da75
1 changed files with 5 additions and 9 deletions

View File

@ -411,18 +411,14 @@
};
web.setDir = function () {
const dir = document.getElementById('dir').checked;
/*$.ajax({
method : 'POST',
url : '/dir',
data : JSON.stringify({ dir : dir}),
contentType: 'application/json',
dataType : 'json',
success : web.setDirSuccess
});*/
const formData = new FormData()
console.log('set to => ' + dir)
formData.append('json', JSON.stringify({ dir : dir }))
const opts = {
method : 'POST',
body : { dir : dir}
body : formData
};
console.dir(opts)
fetch('/dir', opts)
.then(res => {
return res.json()