2011-03-05 68 views

回答

0

你可以簡單地使用target屬性的形式爲:

<form method="post" target="_blank" action="..."> 

注意,儘管這將在所有主要的瀏覽器,它已被廢棄,你的網頁將無法驗證按照W3C標準。

0

有兩種方法可以完成此操作。如果頁面可以重新加載,只需將表單發佈到您當前所在的頁面。如果你想用AJAX提交表單(不需要頁面重載),那麼推薦使用jQuery等javascript庫(爲了節省手動構建XHR請求的麻煩),下面是jQuery與jQuery的一個示例:

window.onload = function(){ 
    $('.image').click(function(){ 
    var image_id = $(this).attr('id'); 
    $.ajax({ 
     type: "POST", 
     url: "/ajaxpage.php", 
     data: { 
      id:image_id 
     } 
     success: function(data){ 
      alert(data); 
     }, 
     failure: function(){ 
      alert('failed'); 
     } 
    }); 
    }); 
} 

從您在此處調用的頁面可以回顯將由ajax成功處理程序處理的響應。