jquery post json
来源:互联网 发布:王侯将相宁有种乎 编辑:程序博客网 时间:2024/05/19 06:36
jquery ajax调用,有的情况下提交的参数比较多,这时我们希望将这些参数作为一个json对象传递到controller中进行处理,那么就需要使用到post json对象的功能,下面的例子简单说明这个功能的使用。
- js代码,需要注意contentType:”application/json”,不然会出现415的错误
<script type="text/javascript"> $(function(){ var para = { name : 'lpn', cname : 'shine' }; var jsonpara = $.toJSON(para); $("#checkName").click(function(){ $.ajax({ url : webContextPath + "/main/checkName", async : true, type : "POST", contentType : "application/json", dataType : "json", data : jsonpara, success : function(response) { var errorInfo = response.errorInfo; if (errorInfo != null) { $("#checkInfo").html(errorInfo); } else { $("#checkInfo").html("name is available"); } }, error : function() { alert("server exception"); } }); }); }); </script>
- controller代码,需要注意@RequestBody的使用,它和@ResponseBody的作用一样,都是数据json处理
@ResponseBody @RequestMapping(value = "/checkName", method = RequestMethod.POST) public Map<String, Object> checkName(@RequestBody CheckNameParam checkNameParam) { System.out.println(checkNameParam.toString()); Map<String, Object> jsonMap = new HashMap<String, Object>(); return jsonMap; }
0 0
- jquery post json
- jquery ajax post json对象
- mvc3 jquery post 复杂json
- (笔记)json+jQuery post+get
- jquery.post获取处理json数据
- Jquery php Json Ajax POST GET
- jquery ajax post方法获取json数据
- jQuery post json数据 服务端异常
- jQuery.get、jQuery.getJSON、jQuery.post无法返回JSON解决办法
- jQuery AJAX JSON Example – jQuery.parseJSON(), $.post() & $.getJSON()
- 使用JQuery+Struts1.3实现JSON的post传递
- JQuery post 回调函数返回 json 数据
- jQuery中ajax和post处理json的不同
- 使用jquery ajax post json数据到jersey resource
- asp.net 中 Json、Jquery、Post简单使用
- jQuery中ajax和post处理json的不同
- 使用jquery和html5 post json格式数据
- JQuery $.POST 返回json数据需注意到几点
- ArcGIS教程:众数滤波 (Spatial Analyst)
- UILabel自适应内容高度总结
- 对学习编程者的忠告
- unity5.X 中的全局光照技术详解(建议收藏)
- Registering iOS Devices for Testing - 注册测试设备
- jquery post json
- windbg 调试
- App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Te
- 快速组合排列算法
- 平板创新,平衡性能与轻薄的矛盾是关键
- android技术集合
- 你的阅读造就了你 You are what you read
- 百度手机卫士,简单粗暴至极(关于Stagefright高危漏洞)
- 用序列完成循环