2012-07-06 58 views
0

成功插入日期後,我想重定向到另一個JSP頁面。通過AJAX成功插入數據後重定向到另一個頁面

$.ajax({ 
       type: "post", 
       url: "register.jsp", 
       data: datastring, 
       success:function(){    
           window.location.href = "nextPage.jsp"; 
       } 

但我不能重定向到另一個頁面(nextPage.jsp),但數據插入到數據庫是成功的。如何重定向到 另一頁?

我也試過

success:function(){ 
$("divid").load("nextPage.jsp") } 

,但是這也不能正常工作。的

回答

2

,而不是做這個

window.location.href = "nextPage.jsp"; 

做到這一點 使用

var url = '<%=request.getContextPath()%>/your_jsp'; 
window.location.replace(url); 
相關問題