關於ssm,前臺html頁面jquery的success回撥函式實現跳轉重新整理問題
阿新 • • 發佈:2018-11-04
$(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程式碼再次重新整理