Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

jQuery serialize form to JSON

function onSubmit( form ){
  var data = JSON.stringify( $(form).serializeArray() ); //  <-----------

  console.log( data );
  return false; //don't submit
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<form onsubmit='return onSubmit(this)'>
  <input name='user' placeholder='user'><br>
  <input name='password' type='password' placeholder='password'><br>
  <button type='submit'>Try</button>
</form>
Comment

jquery serialize form data to object

var data = {};
$(".form-selector").serializeArray().map(function(x){data[x.name] = x.value;}); 
Comment

get form data serialize jquery

   var form_data = $('#add_post').serializeArray(); //encode in JSON string
        var post_title = form_data[0].value;
        var post_description = form_data[1].value;
     
Comment

jquery form serialize object

$(function(){
  $('form').on('submit', function(e){
    e.preventDefault();
    $(this).serializeObject().done(function(o){
      if(window.console) console.log(o);
      var j = JSON.stringify(o);
      alert(j);
      //window.open("data:image/png;base64," + o.userfile.data);
    });
  });
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript on image load 
Javascript :: link in angular 
Javascript :: object keys and values javascript 
Javascript :: disable formcontrol angular 
Javascript :: Round off a number to the next multiple of 5 using JavaScript 
Javascript :: js get meta-tag name 
Javascript :: jQuery CSS Classes 
Javascript :: disable submit button until checkbox is checked javascript 
Javascript :: react cdn 
Javascript :: excel datatable 
Javascript :: UpperCase every first letter in each word in str 
Javascript :: lodash filter object keys 
Javascript :: how to comment in the react javascript 
Javascript :: react native scrollview detect end 
Javascript :: swapping elements in an array 
Javascript :: javascript get 24 hour time 
Javascript :: livewire file upload progress 
Javascript :: fetch api map 
Javascript :: angular event emitter 
Javascript :: javascript domcontentloaded 
Javascript :: multidimensional array push in jquery 
Javascript :: use node js to check if a json file exists 
Javascript :: update node mac to specific version 
Javascript :: npm for node types 
Javascript :: how to check if item is in list js 
Javascript :: array contains object in javascript 
Javascript :: how to make a 2 value after point javascript 
Javascript :: javascript merge objects 
Javascript :: .textcontent 
Javascript :: react toastify dark mode 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =