SpringMvc 使用ajax返回JavaScript
来源:互联网 发布:淘宝店卖家信誉等级表 编辑:程序博客网 时间:2024/06/05 02:00
java程序:
/** * 删除 */@RequestMapping(value = "/deleteBest", method = RequestMethod.POST ,produces = "application/json; charset=utf-8")public @ResponseBodyString deleteBest(Long id,Long bestid) {String error = "参数错误!"; if(id == null || bestid == null){ return "$.message(\"" + Message.Type.success + "\", \"" + error + "\");";}else{Product product = productService.find(id);if(product != null){Set<Product> bests = product.getBestGroup();Iterator<Product> iter = bests.iterator();while(iter.hasNext()){Product p = iter.next();if(p.getId() == bestid){iter.remove();}}product.setBestGroup(bests);productService.update(product);String success = "删除成功!";return "$.message(\"" + Message.Type.success + "\", \"" + success + "\");";}} return "$.message(\"" + Message.Type.success + "\", \"" + error + "\");";}
前台程序:
//删除一个最佳组合function deleteBest(id,bestid){$.ajax({url:"deleteBest.jhtml",type:"post",data:{id:id,bestid:bestid},dataType:"script",success:function(msg){//执行脚本并删除节点eval(msg);$("#li"+bestid).remove();var index = array.indexOf(id);array.remove(index);}});}
0 0
- SpringMvc 使用ajax返回JavaScript
- SpringMVC使用ajax返回json
- 使用springMVC注解 ajax 返回数据
- SpringMVC使用Ajax返回中文乱码
- SpringMVC的AJAX返回
- Ajax使用一+javascript解析Ajax返回的json字符串
- 关于springmvc的controller返回页面无法跳转,使用ajax
- SpringMVC学习—使用ajax返回Json出现乱码解决方法
- springMVC使用ajax返回json对象,用jquery进行解析.
- springMVC+ajax返回JSON串
- SpringMVC+ajax返回JSON串
- ajax SpringMVC如何返回json
- SpringMVC Ajax请求返回404
- SpringMVC Ajax请求返回404
- springMVC实现ajax返回json
- springMVC ajax返回List<Object>
- SpringMvc 中使用ajax
- Springmvc返回值,ajax,重定向
- JAVA List 移除元素
- 天声人語
- 程序员平时该问问自己的10个问题
- Swift学习 第一课,变量与常量
- 内部类
- SpringMvc 使用ajax返回JavaScript
- hibernate常用配置
- web.xml
- 直接调用的CSS超级棒的哦,用过才知道,整理好久才整理出来的,下一篇会发使用说明
- Android中Context详解 ---- 你所不知道的Context
- oracle数据恢复
- [Leetcode] Linked List Cycle
- db2日期和时间常用汇总
- 重建二叉树