$(function() {
var message=GetRequest();
if(message.message!=null){
$CommonUI.alert(message.message);
}
});
function GetRequest() {
var url = location.search; //獲取url中"?"符後的字串
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
strs = str.split("&");
for(var i = 0; i < strs.length; i ++) {
theRequest[strs[i].split("=")[0]]=decodeURI(strs[i].split("=")[1]);
}
}
return theRequest;
}
//登錄
function Login() {
var userName = encodeURI(encodeURI($('input[name="userName"]').val()));
var password = encodeURI($('input[name="password"]').val());
if(userName.length>0&&password.length>0){
//$CommonUI._AJAX_SUCC = false;
postReq($WEB_ROOT_PATH+ '/login/loginCtrl.htm?BLHMI=login&dto.login.userName=' + userName + '&dto.login.password=' + password, "", succ, err, {skipHidden:false});
}else{
alert("賬戶、密碼不能爲空!");
}
}
location.search location js中dom內置對象
var theRequest = new Object()
後面分解爲三個數組對象
theRequest[BLHMI] 值 login
<pre name="code" class="javascript">theRequest[dto.login.username] 值 'username'
<pre name="code" class="javascript">theRequest[dto.login.password] 值 'passwoe'
var str = url.substr(1); //str =BLHMI=login&dto.login.userName=' + userName + '&dto.login.password=' + password
substr(x,y)
x 爲字符的索引,正數從左往右 從0開始 負數從右往左
y 爲截取的字符個數