Jquery 将JSON格式的表单数据发送到Web API操作,而不提交表单
我需要预览表单的内容而不提交表单。这个想法是:Jquery 将JSON格式的表单数据发送到Web API操作,而不提交表单,jquery,json,asp.net-web-api,Jquery,Json,Asp.net Web Api,我需要预览表单的内容而不提交表单。这个想法是: 获取表单数据,例如标签、输入和文本区域值 使用AJAX将数据发送到一个URL,我将在那里“准备”数据 使用()在模板中显示数据 我有一个表单示例: <form method="post"> <label for="Name">Full Name</label> <input type="text" value="John" id="Name"> <label for="CV">
<form method="post">
<label for="Name">Full Name</label>
<input type="text" value="John" id="Name">
<label for="CV">Curriculum Vitae</label>
<textarea value="I am ..." id="CV" data-parser="markdown">I am ...</textarea>
<label for="Roles">User Roles</label>
<select id="Roles">
<option value="1" selected>Admin</option>
<option value="2">Collaborator</option>
</select>
<label for="Active">Active</label>
<input type="checkbox" value="true" id="Active">
</form>
我想得到一个JSON对象,这样我就可以操纵它并返回到Sidr中显示它
我还需要在数据解析器中发送存在的值
例如,textarea具有data parser=“markdown”
如何获取表单数据并以JSON格式将其发送到ASP.NET Web API操作
谢谢,,
Miguel使用jQuery序列化表单,然后发送给控制器:
Full Name: John (Label text and Input value)
Curriculum Vitae: I am ... (Label text and Input value)
Roles: Admin (Label text and Selected option)
...