caliber-i
10/17/2017 - 2:59 PM

collect input fields data and build a json using key as a input name and value as input value. give a HTML form as a parameter

collect input fields data and build a json using key as a input name and value as input value. give a HTML form as a parameter

let buildFormJSON = function(form) {
  let json = {};
  $.each($(form).find('input'), function(k, v){
    let key = $(v).attr('name');
    let value = $(v).val();

    if(key !== undefined) {
      json[key] = value;
    }
  });
  return json;
}

//comment