0

I want to collect the data with Json when the button is pressed. Could someone send me a example with the best way to do this? I used JS to make a function on the button but I can't figure out how to use Json.

This is my HTML code:

<body>
 <div class="formclass">
        <form method="post" name="myform">
          <div class="input-group">
            <input id="name" type="text" name="name" placeholder="Name">
            <input id="city" type="text" name="city" placeholder="City">
            <button type="button" id="insert">Submit</button>
          </div>
        </form>
     </div>
   </body>

Bas

  • 1
    Possible duplicate of [How to send a JSON object using html form data](http://stackoverflow.com/questions/22195065/how-to-send-a-json-object-using-html-form-data) – LordMarty Feb 01 '17 at 21:23

1 Answers1

1

var formData = JSON.stringify($("#myForm").serializeArray());

How to send a JSON object using html form data

Community
  • 1
  • 1
LordMarty
  • 1,551
  • 1
  • 12
  • 17