LJ Wadowski
LJ Wadowski

Reputation: 6720

Add post variables to form send with FormData() via AJAX

Because I want attach files to upload I'm trying to send a form using new FormData(myForm), however I want to add to post some data which not coming from the form.

Previously before I needed to upload file I used serializeArray() and it was pretty easy to add some data to array.

I know that I can add some hidden inputs but I don't like this solution.

Is there any better solution to manipulate form data before send it with FormData()?

Upvotes: 0

Views: 860

Answers (1)

Barmar
Barmar

Reputation: 781583

You can use FormData.append(). It's described in the FormData API documentation

Upvotes: 2

Related Questions