New version of mootools ajax timeout
This does not work much better then the previous version, but it triggers a "real" event...
- /*
- Class: Ajax
- timeout for the ajax class
- Options:
- timeout - timeout in milliseconds; default is none
- onTimeout - timeout event
- Author:
- Stefan Lange-Hegermann
- */
- Ajax = Ajax.extend({
- options: {
- onTimeout:Class.empty
- },
- request: function(){
- if (this.options.timeout) {
- this.timeoutTimer=window.setTimeout(this.callTimeout.bindAsEventListener(this), this.options.timeout);
- this.addEvent('onComplete', this.removeTimer);
- }
- this.parent();
- },
- callTimeout: function () {
- this.transport.abort();
- this.onFailure();
- this.fireEvent('onTimeout');
- },
- removeTimer: function() {
- window.clearTimeout(this.timeoutTimer);
- }
- });




Hi Stefan,
It looks like your request function unintentionally strips off the data payload that had been sent with the ajax request. A simple fix: