How to get a key/value data set from a HTML form?

JavascriptWeb DevelopmentFront End Scripts

To get a key/ value data set from a HTML form, use jQuery.

Let us say this is our HTML −

<form id = "form1">
   <input type = "text" name = "demo" />
</form>

For JS −

var data = $('form#form1’).serializeArray(); // [{'demo: 'value'}]
$.ajax({
   data: data
});
raja
Updated on 25-Jun-2020 06:19:04

Advertisements