var page = "https://dynamic.12306.cn/otsweb/loginAction.do?method=init";
var url = "https://dynamic.12306.cn/otsweb/loginAction.do?method=login";
var queryurl = "https://dynamic.12306.cn/otsweb/order/querySingleAction.do?method=init";
function submitForm() {
var _ifrMain = document.getElementById('main');
var userName = _ifrMain.contentWindow.document.getElementById('UserName');
var password = _ifrMain.contentWindow.document.getElementById('password');
var randCode = _ifrMain.contentWindow.document.getElementById('randCode');
var subLink = _ifrMain.contentWindow.document.getElementById('subLink');
var submitUrl = url;
$.ajax({
type: "POST",
url: submitUrl,
data: {
"loginUser.user_name": userName.value
, "user.password": password.value
, "randCode": randCode.value
},
timeout: 30000,
success: function (msg) {
if (msg.indexOf('请输入正确的验证码') > -1) {
alert('请输入正确的验证码!');
};
if (msg.indexOf('当前访问用户过多') > -1) {
reLogin(msg);
}
else {
location.replace(queryurl);
};
},
error: function (msg) {
reLogin(msg);
},
beforeSend: function (XHR) {
;
}
});
}
var count = 1;
function reLogin(msg) {
count++;
subLink.innerHTML = "(" + count + ")次登录中..." + msg;
setTimeout(submitForm, 500);
}
submitForm();