0

I'm trying to get the form data from my form returned as a simple map Object {a: "b", c: "d"}

I know I can .serialize() and .serializeArray() and then do it myself. Isn't there a jQuery function or something vailable for that?

Matt Cain
  • 5,638
  • 3
  • 36
  • 45
Timo
  • 930
  • 2
  • 10
  • 22
  • Please provide some code – Stefan Jun 21 '13 at 14:40
  • 1
    No, there isn't. $.map and $.serializeArray both return arrays rather than objects (it's called an object, not a map). The only option is looping over the fields using either a for loop while loop or an each loop. – Kevin B Jun 21 '13 at 14:41
  • Have you check this : https://stackoverflow.com/questions/1184624/convert-form-data-to-javascript-object-with-jquery/39248551#39248551 – Bhavik Hirani Mar 26 '18 at 08:01

1 Answers1

1

There is no straight conversion form formdatato JSON. But here is a way to solve the problem: http://blog.erdemagaoglu.com/post/1231059494/serialize-form-data-to-json-with-jquery

Thomas Junk
  • 5,588
  • 2
  • 30
  • 43