function submitForm(){ var submitUrl = url; $.ajax({ type: "POST", url: submitUrl, data: { "loginUser.user_name": $("#UserName").val() , "user.password": $("#password").val() , "randCode": $("#randCode").val() }, beforeSend: function( xhr ) { try{ xhr.setRequestHeader('X-Requested-With', {toString: function(){ return ''; }}); xhr.setRequestHeader('Cache-Control', 'max-age=0'); xhr.setRequestHeader('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'); }catch(e){}; }, timeout: 30000, //cache: false, //async: false, success: function(msg){ //密码输入错误 //您的用户已经被锁定 if ( msg.indexOf('请输入正确的验证码') > -1 ) { alert('请输入正确的验证码!'); } else if ( msg.indexOf('当前访问用户过多') > -1 ){ reLogin(); } else if( msg.match(/var\s+isLogin\s*=\s*true/i) ) { notify('登录成功,开始查询车票吧!'); window.location.replace( queryurl ); } else { msg = msg.match(/var\s+message\s*=\s*"([^"]*)/); if( msg && msg[1] ) { alert( msg && msg[1] ); } else { reLogin(); } } }, error: function(msg){ reLogin(); } }); }