2013-04-02 67 views
0

我在Microsoft Active Directory證書服務器上有一個「用戶證書」表單。 形式託管的網址:在頁面加載時使用JQuery提交表單

https://mycaserver/certsrv/certrqbi.asp?type=0. 

這種形式簡化的HTML是:

<html> 
<body> 
<Form Name=SubmittedData Action="certfnsh.asp" OnSubmit="return goNext();" Method=Post> 
    <Input Type=Hidden Name=Mode>    <!-- used in request ('newreq'|'chkpnd') --> 
    <Input Type=Hidden Name=CertAttrib>  <!-- used in request --> 
    <Input Type=Hidden Name=FriendlyType>  <!-- used on pending --> 
    <TR><TD></TD> 
     <TD ID=locSubmitAlign Align=Right> 
     <Input ID=locBtnSubmit Type=Submit Name=btnSubmit Value="Submit &gt;" > 
    </TD></TR> 
</Table> 
</Form> 
</body> 
</html> 

我想:

  • 使用jQuery加載HTML頁面的網址上面並自動點擊提交按鈕。
  • 然後點擊提交後檢查響應以搜索子字符串。

有人能給我一些指點嗎?

非常感謝

+0

如果你用jQuery加載url(假設啓用CORS),表單的動作將不再指向正確的位置,除非你的服務器也有這個動作。儘管如此,您仍然可以對CORS POST進行所需的操作。 –

回答

0

您可以使用ajax post發送您的形式,檢查的結果。把窗體上的ID「SubmittedData」,使事情變得更容易,

此外,你應該加載此加載JQuery的時候,而不是在頁面加載(小的差別有:

$(document).ready(function(){ 
    $.post('certfnsh.asp', $("#SubmittedData").serialize(), function(data) { 
     alert(data); 
    }); 
}); 
0

這裏你有一個起點

$(document).ready(function(){ 
    $('form[name="SubmittedData"]').unbind().on('submit', function(){ 
    var t = $(this); 
    $.ajax({ 
     type : t.attr('method'), 
     url : t.attr('action'), 
     data : t.serialize(), 
     success : function(d){ 
     //Check the result in firebug (chrome developer tools) console 
     console.log(d); 
     // do rest of stuff after submitting for is ok 
     //alert(d); //use this if you do not have firebug 
     }, 
     error : function(xhr, opts, error){ 
     console.log(error); 
     } 
    }); 
    }).trigger('submit'); 
}); 

我不明白的第二點,你正好需要的。你也許以後我們展示你的「成功」的步驟,我們可以用代碼的其餘部分發揮什麼樣的。

相關問題