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
Post a Comment