2012-07-24 64 views
-3

在JSP中,我想在表單提交後執行對另一個JSP的調用,並且因爲它已經被使用,我不能使用動作attribue?在不使用動作的情況下調用頁面JSP中的屬性

我想調用另一個具有上述限制的JSP。

嘗試使用jQuery

">" $('#form2').submit(function(event) { $.ajax({ ">" 

但沒有工作..

回答

0

您可以通過以下方式

裝上此代碼對任何事件像的onclick

function post(){ 
//Get your form inputs 
var myID = $("#myID ").val(); 
var myName = $("#myName").val(); 

//post your data 
var request = $.ajax({ 
    url: "thepagewhichhasform.jsp", 
    type: "POST", 
    data: {id : myID , name : myName }, 
    dataType: "html" 
}); 

//When post is completed 
request.done(function(msg) { 
    //change the page 
    window.location.href = "theotherpage.jsp"; 
}); 

return false; 
} 
相關問題