window.addEvent('load', function() {
$('login').focus();
});
function Login() {
var ms = null;
new XHR({
method: 'POST',
async: true,
encoding: 'UTF-8',
onRequest: function() {
ms = Utility.MessageBox.message('用户登录中...');
},
onSuccess: function(txt) {
ms.close();
window.location.replace(txt);
}
}).send('./UserLogin.do', null);
}
那位高手帮忙看一下
能帮我解释一下么?!
$('login').focus();
});
function Login() {
var ms = null;
new XHR({
method: 'POST',
async: true,
encoding: 'UTF-8',
onRequest: function() {
ms = Utility.MessageBox.message('用户登录中...');
},
onSuccess: function(txt) {
ms.close();
window.location.replace(txt);
}
}).send('./UserLogin.do', null);
}
那位高手帮忙看一下
能帮我解释一下么?!
其中事件是load,应该为onload事件
第二参数为这个事件触发时执行的方法,代码
function() {
$('login').focus();
}这段代码中$('login')是prototype的一个方法,与document.getElementById('login')一样,用于通过id获得一个对象
然后focus()让这个对象获得焦点XHR没用过,不过很容易理解,似乎不是prototype自带的,看里面的代码应该是一个ajax的功能
这个对象的构造函数传进两个参数,最后调用XHR的send方法向./UserLogin.do资源去请求
其中这两个参数里又有较复杂的参数列表,
仔细一看就明白了
参数一:
method: 'POST',
方法为post
async: true,
该方法是同步的
encoding: 'UTF-8',
编码为utf8onRequest: function() {
ms = Utility.MessageBox.message('用户登录中...');
}
onRequest为一个函数的对象
参数二:
onSuccess: function(txt) {
ms.close();
window.location.replace(txt);
}
当请求成功时调用该函数