I'm making a Form purely in JS using a FormData Object (so without a real HTML Form) that I want to submit with POST method to another URL with a redirect (in the same way as I compile a form and press the Submit button getting redirected to the action URL).
I've tried with this code:
function sendFileToDetailsStep(fileToUpload) {
var formData = new FormData();
formData.append("file", fileToUpload);
formData.append("csrfmiddlewaretoken", "{{ csrf_token() }}");
formData.set("method", "POST");
formData.set("action", "{{ route('quotation.details') }}");
formData.submit();
}
But I get a error "Uncaught (in promise) TypeError: formData.submit is not a function", where I'm wrong?