Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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

form data to json

function formDataToJson(formData){
    let json = {};
    if(!(formData instanceof FormData)) return json;
    formData.forEach((value,key)=>{
        json[key] = value;
    });
    return json;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: js date is weekend 
Javascript :: build apk react native 
Javascript :: javascript get data attribute of selected option 
Javascript :: js addeventlistener click 
Javascript :: express js list all routes 
Javascript :: add option to select jquery 
Javascript :: add and remove checked jquery 
Javascript :: loopback model properties 
Javascript :: javascript truthy switch 
Javascript :: get element by xpath in javascript 
Javascript :: webpack-bundle-analyzer no stats.json file 
Javascript :: select element by data attribute 
Javascript :: isobject javascript 
Javascript :: checking if a character is an alphabet in js 
Javascript :: locate and delete an object in an array 
Javascript :: sh 1 nodemon not found heroku 
Javascript :: Another debugger is already connected Rn @ bundle.js:10 
Javascript :: unrecognized json property java 
Javascript :: ionic 4 get previous route 
Javascript :: convert base64 to uint8array javascript 
Javascript :: js save session 
Javascript :: Make Array Consecutive javascript 
Javascript :: js vanilla when i remove one object it removes all of them 
Javascript :: upsert mongoose 
Javascript :: csrf token ajax header 
Javascript :: javascript clear all intervals 
Javascript :: email validation in react js 
Javascript :: search box enter key javascript 
Javascript :: disable mouse right click javascript 
Javascript :: onpress image react native 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =