Discuss / JavaScript / 获取表单的JSON字符串

获取表单的JSON字符串

Topic source

An安晓婷

#1 Created at ... [Delete] [Delete and Lock User]
json={
}
var myform = $("#test-form");
json.name=myform.find("[name=name]").val();
json.email=myform.find("[name=email]").val();
json.password=myform.find("[name=password]").val();
json.gender=myform.find("[name=gender]:checked").val();
json.city=myform.find("option:selected").val();
json = JSON.stringify(json);

  • 1

Reply