Skip to content

Sending FormData() via sendAsyncEvent() throws error #1998

@Bloke

Description

@Bloke

I'm trying to send FormData (that includes a file) to a back-end plugin:

let thisform = document.getElementById('formName');
let formData = new FormData(thisform);
console.log(formData);
sendAsyncEvent({
    event: 'smd_some_plugin',
    step: 'do_stuff',
    data: formData
}, function(data, res, xhr) {
	console.log(data);
}, 'json');

When I take action on the webpage and sendAsyncEvent() is called I get this thrown in the console:

'append' called on an object that does not implement interface FormData.

Searching around, everyone says that in order to successfully send FormData, we need processData: false, contentType: false. We already have that in place.

I wondered if it maybe needed some multipart mime header, but I took the file out of the form and it still emitted the same error message with just text boxes and selects in the form. The formData looks okay in the console.

Is this PEBKAC? Any ideas, @bloatware?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions