I’d like to wrap Prototype Ajax.Request in order to simulate AJAX latency. I mean, using a closure and Prototype’s delay() facility, but apparently there is something wrong with my code
/*
* Purpose: simulate AJAX latency when developing on localhost
* What's wrong?
*/
Ajax.Request = (function(original) {
return function(url, options) {
return original.delay(1, url, options);
};
}) (Ajax.Request);
This worked for me (using prototype 1.6.1):
I believe the method signature for
Ajax.Request.prototype.initializeis different in older version of prototype (i.e. without the $super parameter).This will update it for all Ajax requests though.