Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (7k points)

Is there any way to serialize a form in JavaScript without using frameworks like Jquery?

1 Answer

0 votes
by (13.1k points)

You can use URLSearchParms and FormData(formELement) which are compatible with most modern browsers you can do it like this:

new URLSearchParams(new FormData(formElement)).toString()

If you want it to be compatible with older browsers like IE10 then you have to use Array. from like this:

Array.from(

new FormData(formElement),

e=>e.map(encodeURIComponent).join(‘=’)).join(‘&’)

Want to be a web developer? Check out the full stack developer course from Intellipaat. 

Related questions

0 votes
1 answer
asked Mar 28, 2021 in Web Technology by Jake (7k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...