在页面加载时使用JQuery提交表单
我的Microsoft Active Directory证书服务器上有“用户证书”表单。 该表单位于URL上:在页面加载时使用JQuery提交表单,jquery,html,forms,certificate-authority,Jquery,Html,Forms,Certificate Authority,我的Microsoft Active Directory证书服务器上有“用户证书”表单。 该表单位于URL上: https://mycaserver/certsrv/certrqbi.asp?type=0. 此表单的简化html为: <html> <body> <Form Name=SubmittedData Action="certfnsh.asp" OnSubmit="return goNext();" Method=Post> <Inp
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 >" >
</TD></TR>
</Table>
</Form>
</body>
</html>
我想:
- 使用Jquery加载上面html页面的URL,并自动单击submit按钮
- 然后单击submit之后,检查响应以搜索子字符串
$(document).ready(function(){
$.post('certfnsh.asp', $("#SubmittedData").serialize(), function(data) {
alert(data);
});
});
这里有一个起点
$(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' );
});
我不明白第二点,你到底需要什么。也许在你向我们展示了你在“成功”步骤中得到了什么之后,我们可以使用剩下的代码。如果你用jQuery加载url(假设启用了CORS)表单的操作将不再指向正确的位置,除非您的服务器也有该操作。不过,您可以再次向所需的操作执行CORS POST。