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

PREVIOUS NEXT
Code Example
Javascript :: Iterate Odd Numbers With a For Loop 
Javascript :: random alphabet javascript 
Javascript :: javascript sort by id 
Javascript :: javascript date to utc format 
Javascript :: javascript format numbers with commas 
Javascript :: create hash password in js 
Javascript :: Axios GET Req with Basic Auth 
Javascript :: your mom is your dad 
Javascript :: react load different .env for local, dev, and prod 
Javascript :: delete attribute javascript 
Javascript :: rails is not defined javascript 
Javascript :: how to send an embed message discord.js 
Javascript :: console.clear js 
Javascript :: uuid use in express 
Javascript :: how to get browser url in javascript 
Javascript :: react change button color on hover 
Javascript :: mongodb count conditional array items 
Javascript :: @jsonignore unrecognized field 
Javascript :: angular how to get previous state 
Javascript :: javascript allow only alphanumeric characters 
Javascript :: observable.create is deprecated 
Javascript :: javascript upload json 
Javascript :: how to get sys time in js 
Javascript :: create parent div javascript 
Javascript :: jquery on input 
Javascript :: toggle multiple classes jquery 
Javascript :: javascript loop over classes 
Javascript :: js remove spaces 
Javascript :: how can search in object in array 
Javascript :: get value of span jquery 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =