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
Published on 05-Apr-2018 13:23:33
Advertisements