使用示例
<script type="text/javascript" src="../scripts/prototype.js"></script>
<script type="text/javascript">
var progressBar;
/**//*
* 功能:admin登錄
*/
function UserLogin()
{
//驗證頁面控件
var checkform = new CheckForm();
if(!checkform.checkForm(document.getElementById('formLogin'))) return false;
//開始提交數據
progressBar = new ProgressBar();
progressBar.SetStatus("正在發送數據到服務器.");
var url = "../admin.do";
var pars = "action=Login&username=" + $F('username') + "&password=" + $F('password') + "&rnd=" +$F('rnd');
var myAjax = new Ajax.Request(
url,
{method: 'post', parameters: pars, onComplete: UserLogin_CallBack}
);
}
/**//*
* 功能:admin登錄 - CallBack
*/
function UserLogin_CallBack(originalRequest)
{
var objXml = originalRequest.responseXML;
//alert(originalRequest.responseTEXT);
try
{
if(objXml.getElementsByTagName("return")[0].firstChild.nodeValue == "true")
{
progressBar.isNeedConfirmButton = false;
progressBar.isNeedProgressBar = true;
progressBar.SetStatus("<img src='/images/NullPic.gif' align='absmiddle'> 登錄成功,正在載入,請稍候..");
//login success
location.href='admin_index.htm';
}
else
{
progressBar.isNeedConfirmButton = true;
progressBar.isNeedProgressBar = false;
progressBar.focusItem = "username";
progressBar.SetStatus("<img src='/images/NullPic.gif' align='absmiddle'> 對不起,登錄失敗!" + objXml.getElementsByTagName("msg")[0].firstChild.nodeValue);
$('btnOK').disabled = false;
}
}
catch(err)
{
progressBar.isNeedConfirmButton = true;
progressBar.isNeedProgressBar = false;
progressBar.focusItem = "username";
progressBar.SetStatus("<img src='/images/NullPic.gif' align='absmiddle'> 對不起,登錄失敗!" + err.message);
$('btnOK').disabled = false;
}
}
</script>
<table width="100%" border="0" cellpadd