prototype中的一段代码看不懂,顶者有分
Ajax.Request.prototype = (new Ajax.Base()).extend({
initialize: function(url, options) {
this.transport = Ajax.getTransport();
this.setOptions(options);
this.request(url);
},
/**
* 新增加 request 方法封装 xmlhttp 的调用过程。
*/
request: function(url) {
var parameters = this.options.parameters || ''; //就是这里,this.options.parameters是函数的参数吧,或上一个空的字符串'',不就是bool型了吗,可是好像这样不对的说。却新定义一个parameters,又什么意思啊。希望得到各位大哥的指点,感激不尽。
if (parameters.length > 0) parameters += '&_=';
try {
if (this.options.method == 'get')
url += '?' + parameters;
this.transport.open(this.options.method, url,
this.options.asynchronous);
if (this.options.asynchronous) {
this.transport.onreadystatechange = this.onStateChange.bind(this);
setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10);
}
this.setRequestHeaders();
var body = this.options.postBody ? this.options.postBody : parameters;
this.transport.send(this.options.method == 'post' ? body : null);
} catch (e) {
}
}
}