A
A
Andrei1penguin12021-03-12 14:20:59
AJAX
Andrei1penguin1, 2021-03-12 14:20:59

How to get data from FormData on server side?

Good day, through ajax data goes to the server in the form FormData, that is, when reading the form on the server, [object FormData] is returned.
Actually, the question itself is: how to get data from this form on the server?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alekssamos, 2021-03-14
@Andrei1penguin1

Damn it! It's hard for you! You can add only strings with strings, numbers only with numbers. But different objects are not allowed! FormData is not a string that contains a URL, it's an object!
request.send(form);
And that's it! Understand?
Output through alert try and you will understand what is wrong!
The rest of the data is of the type data = add something there by analogy through .append.
And one more thing: the form can be created from an HTML form that you already have on the page!

form = new FormData( document.getElementsByTagName("form")[0] );

D
Dr. Bacon, 2021-03-12
@bacon

request.send("data"+form);
oh, someone else needs to learn js in order not to write this, although here, of course, it’s not about understanding the language, but about common sense. Do you understand what you did here?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question