关于ssm,前台html页面jquery的success回调函数实现跳转刷新问题

$(function(){
$.ajax({
type:“post”,
url:"…/…/b/k.action",
dataType: “json”,
success:function(data){
$(data).each(function(k,v){

			 $("tbody").append("<tr><td>"+$(this).attr('id')+"</td>"
					 +"<td>"+$(this).attr('title')+"</td>"
					 +"<td>"+$(this).attr('author')+"</td>"
					 +"<td>"+$(this).attr('releaseTime')+"</td>"
					 +"<td>" +"<a href='../../b/l.action?id="+$(this).attr('id')+"'>删除</a>"+
					 "</td></tr>");
		 })
	},
	error:function(){
		alert("失败");
	}
});

});

当加载这个页面时,页面刷新,将数据渲染到页面上。
同时当点击回调函数的超链接进行删除时,再跳会原来页面,发现数据渲染不上

解决办法:

@RequestMapping(“l”)
public String l(String id) {
System.out.println(id);
int a=Integer.parseInt(id);
userService.deleteNotice(a);
return “redirect:/houtai/notice/noticeInfo.html”;
}
将springMVC视图跳转改为重定向,可实现,删除操作后,jquery代码再次刷新

猜你喜欢

转载自blog.csdn.net/wanwenjieGood/article/details/83590511