D
D
Dmitry Tarasov2017-09-11 01:32:13
JavaScript
Dmitry Tarasov, 2017-09-11 01:32:13

How to convert data from html form to json?

How can I convert any kind of data from html form to json using vanilla js?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
iRedds, 2017-09-11
@iRedds

via formdata.

S
Stalker_RED, 2017-09-11
@Stalker_RED

If you need to send via AJAX, then you can use FormData .

var data = new FormData(myForm);
var req = new XMLHttpRequest();
req.send(data);

If you need it in JSON, then something like this: https://code.google.com/archive/p/form-serialize/d...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question