Simulate AJAX Delay with Packaging Closing

I would like to wrap Prototype Ajax.Request to mimic AJAX latency. I mean using the close function and Prototype delay (), but apparently with my code

something is wrong.
/*
 * Purpose: simulate AJAX latency when developing on localhost
 * What wrong?
 */
Ajax.Request = (function(original) {
  return function(url, options) {
          return original.delay(1, url, options);
  };
}) (Ajax.Request);
+3
source share
1 answer

This worked for me (using prototype 1.6.1):

Ajax.Request.prototype._initialize = Ajax.Request.prototype.initialize;

Ajax.Request.prototype.initialize = function ($super, url, options) {
  return this._initialize.bind(this).delay(2, $super, url, options);
};

I believe that the method signature for Ajax.Request.prototype.initializediffers from the old prototype version (i.e. without the $ super parameter).

This will update it for all Ajax requests.

+1
source

Source: https://habr.com/ru/post/1757965/


All Articles