Answer the question
In order to leave comments, you need to log in
How to convert serialized string to JSON in JavaScript and jQuery?
Good evening!
Are there better options for converting a string returned by a jQuery methodserialize()
to a JSON string usingJSON.Stringify()
?
Answer the question
In order to leave comments, you need to log in
Have you even tried googling yourself? Well, it's 3 seconds.
function onSubmit( form ){
var data = JSON.stringify( $(form).serializeArray() ); // <-----------
console.log( data );
return false; //don't submit
}
<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>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question