updater.js 556 B

1234567891011121314151617181920
  1. var updater = Class.create({
  2. initialize: function(divToUpdate, interval, file) {
  3. this.divToUpdate = divToUpdate;
  4. this.interval = interval;
  5. this.file = file;
  6. new PeriodicalExecuter(this.getUpdate.bind(this), this.interval);
  7. },
  8. getUpdate: function() {
  9. var oOptions = {
  10. method: "POST",
  11. parameters: "intervalPeriod="+this.interval,
  12. asynchronous: true,
  13. onComplete: function (oXHR, Json) {
  14. $(this.divToUpdate).innerHTML = oXHR.responseText;
  15. }
  16. };
  17. var oRequest = new Ajax.Updater(this.divToUpdate, this.file, oOptions);
  18. }
  19. });