<script type="text/javascript">
function doAjax(paras) {
var _xhr = new XMLHttpRequest();
var _paras = paras || {url:'good', type:'get', func:function(){}};
_xhr.onreadystatechange=_paras.func(_xhr); // 如何解释,带参数?
// 但是返回的函数不带参数。
_xhr.open(_paras.type,_paras.url,true);
_xhr.send(null);
}
doAjax({
url: 'good',
type: 'get',
func: function(xhr) {
return function() { // 闭包,誰能解释下?
if(xhr.readyState==4&&xhr.status==200) {
alert(xhr.responseText);
}
};
}
});
</script>