2012-04-10 99 views
0

我有一個aspx頁面,我需要調用而不直接在該頁面上。
我試圖從表單發佈POST,但它在瀏覽器中打開這個動作URL。
如何在不打開它的情況下調用aspx頁面

<form method="POST" action="http://mysite/actionpage.aspx"> 

     <input type="submit" value="Submit" /> 
     </form> 

回答

1

你可以使用curl,如果你是在* nix系統上。

以下是如何將數據發佈到頁面的參考。結果將通過命令行返回。

What is the curl command line syntax to do a post request?

下面是引用的語法:

curl -d "param1=value1&param2=value2" http://example.com/resource.cgi

curl -F "[email protected]" http://example.com/resource.cgi

+0

我不能使用ajax,所以這是完美的謝謝。 – 1110 2012-04-10 12:56:48

1

如果jQuery是允許你的情況來使用,你可以使用jQuery的AJAX調用該網頁

$("form").submit(function(e){ 
    e.preventDefault(); 
    $.post("yoursecondpage",function(data){ 
     //do whatever with the response from that page 
    });  
    }); 
1

您可以通過AJAX做到這一點。 例如,如果您添加腳本參考jQuery的事情會變得容易得多,你可以做到以下幾點:

<script type="text/javascript"> 
    function postIt() 
    { 
    $.post( 
     "http://mysite/actionpage.aspx" 
     , function(data) 
     { 
      // data was returned from the server 
      alert("data posted in the background"); 
     }); 
    } 
</script> 

你可以通過後臺進行處理。

你最後竟被HTML是:

<form method="POST" action="http://mysite/actionpage.aspx">  

     <input type="submit" value="Submit" onclick="postIt();" />  
    </form>  
0

我沒有測試過,但看起來像你導航爲.aspx意味着服務器頁面,即你需要使用RUNAT =「服務器」你這樣的標籤

+0

我認爲情況並非如此。添加它仍然會使後發生。 – ClayKaboom 2012-04-10 13:17:42

相關問題