html页面发送请求处理json
2015-07-01 10:10
447 查看
通过JS方式发送请求
htmlcode:通过onclick触发
<a href="" onclick="del()" >删除</a> <script type="text/javascript"> function del(){ if(window.confirm("是否删除?")){ $.ajaxSetup({ async : false }); var id = document.getElementById("pid").value; var url = "${contextPath}/publishEdit/delMsg"; var paras = {id : id}; $.get(url,paras,function(data){ if(data.RETCODE ==="1"){ alert("删除成功!") window.location = "${contextPath}/published"; }else{ alert("删除失败!"); return; } }); }else{ window.location = "${contextPath}/published"; } } </script>
controller:
public void delMsg(){ String id = getPara("id"); boolean isDel = publishService.delContent(id); Record r = new Record(); if(isDel){ r.set("retcode", "1"); }else { r.set("retcode", "0"); } renderJson(r.toJson()); }
相关文章推荐
- XML 与 JSON 优劣对比
- newtonsoft.json解析天气数据出错解决方法
- vbs 解析json jsonp的方法
- jquery JSON的解析方式示例介绍
- c#版json数据解析示例分享
- ASP JSON类文件的使用方法
- C#实现对Json字符串处理实例
- C#实现Json转Unicode的方法
- php解析json数据实例
- PHP6 先修班 JSON实例代码
- 关于JSON以及JSON在PHP中的应用技巧
- .Net中的json操作类用法分析
- JavaScript中字符串(string)转json的2种方法
- js Object2String方便查看js对象内容
- C#中的DataSet、string、DataTable、对象转换成Json的实现代码
- Json实现异步请求提交评论无需跳转其他页面
- javascript格式化json显示实例分析
- jquery处理json数据实例分析
- jQuery向后台传入json格式数据的方法
- jquery中ajax调用json数据的使用说明