javascript - How to store JSON in a variable -


how store data json database, when user registers information should stored in variable?

example:

my html form consists of input text fields firstname, lastname. clicking register button of form should store values of firstname , lastname in variables.

how can this:

 var txt = '{"employees":[' +    '{"firstname":"john","lastname":"doe" },' +     '{"firstname":"anna","lastname":"smith" },' +      '{"firstname":"peter","lastname":"jones" }]}'; 

easily use jquery

var jsonarray; jsonarray.push($("#firstname").val(); jsonarray.push($("#lastname").val(); var myjsonstring = json.stringify(jsonarray); 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -