我个人的观点:出错原因:alert()将程序中断,在点击alert()之前所有操作都是停止的,所以虽然提交并通过了cognos认证,但页面不跳转;一旦点击了alert(),程序继续运行,提交第二个表单,页面才跳转到所需的页面。解决方案:通过ajax技术提交表单。先提交cognos认证,在提交系统登录信息。例...
显示全部我个人的观点:
出错原因:alert()将程序中断,在点击alert()之前所有操作都是停止的,所以虽然提交并通过了cognos认证,但页面不跳转;一旦点击了alert(),程序继续运行,提交第二个表单,页面才跳转到所需的页面。
解决方案:通过ajax技术提交表单。先提交cognos认证,在提交系统登录信息。例如:
var xhr;
function CAMLogon(){
createXHR();
xhr.onreadystatechange = CAMLogonCallback;
xhr.open("get", "http://xxxxx:9300/p2pd/servlet/dispatch?b_action=xts.run&m=portal/main.xts&h_CAM_action=logonAs&CAMUsername=xxxxxxxx&CAMPassword=xxxxxxxx&CAMNamespace=xxxxxxxxxx");//认证参数自行修改
xhr.send();
}
function createXHR(){
if(window.ActionXObject){
xhr = new ActiveXObject("Micrasoft.XMLHTTP");
}else{
if(window.XMLHttpRequest){
xhr = new XMLHttpRequest();
}
}
}
function CAMLogonCallback(){
if(xhr.redystate==4){
if(xhr.status==200){
alert("CAMlogon success");
logon();
}
}
}
function logon(){
createXHR();
xhr.onreadystatechange = logonCallback;
xhr.open("get", "
");//登录参数自行修改,拼串也可以
xhr.send();
}
function logonCallback(){
if(xhr.redystate==4){
if(xhr.status==200){
//alert("xhr.responseText");显示返回值
alert("logon success");
window.location("");//可指定跳转页面
}
}
}
/*流程说明:
1. 调用CAMLogon(),发送认证请求,页面不会跳转
2. 认证成功后才调用logon(),发送系统登录的请求
3. 登录成功后,通过logonCallback()可以将页面跳转到指定url
*/
收起