如何将表单转换成json通过AJAX传递
展开全部
<form id="formId" >
<input id ="name" type="text"/>
<button type="submit" onclick="submitBtn" >提交</button>
</form>
<script>
submitBtn function(){
$.ajax({
url:'xxxAction!.xxx?json',
data:{
"param.name":$('#name').val()
},
.....
});
}
</script>
后台springMvc
xxxAction.java
@RequestBody
@RequestMapping(params="json" value="")
xxx(JSONObject param ){
system.out.println(param);
}
<input id ="name" type="text"/>
<button type="submit" onclick="submitBtn" >提交</button>
</form>
<script>
submitBtn function(){
$.ajax({
url:'xxxAction!.xxx?json',
data:{
"param.name":$('#name').val()
},
.....
});
}
</script>
后台springMvc
xxxAction.java
@RequestBody
@RequestMapping(params="json" value="")
xxx(JSONObject param ){
system.out.println(param);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询