prototype的Ajax.Request中为onSuccess绑定方法

prototype的Ajax.Request中为onSuccess绑定方法,原来也不是那么直接。

如果是在对象内部定义的方法,则需要用onSuccess:this.method_name.bind(this);
如果是对象外的方法,则就能使用
        onSuccess:function(transport) {
            displayAddResult(transport.responseText);
        }, 


并且如果server有时会返回304(内容无变化),则这时onFailture方法也会执行。因此此时最好仅使用onSuccess属性。

结题。

你可能感兴趣的:(function,server,prototype)