self.log() is not a function : completeCallback have not context of "this"

Bug #652335 reported by Tony Cuny
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
jQuery Poll
New
Undecided
Unassigned

Bug Description

Hi,

When completeCallback() is executed "self" is "window" and "this" is "$.ajax", you could make those changes :

Poller.prototype.fetchNow = function() {
         var calls = {
             ifModified: true,
             complete: $.proxy(this.completeCallback, this), // use $.proxy to pass "this" as the context of completeCallBack()
             data: this.dataCallback(),
         };
         var opts = $.extend(true, calls, this.settings);
         $.ajax(opts);
     };

Poller.prototype.completeCallback = function(xhr, textStatus) { // replace "self" by "this"
         this.log('complete: '+textStatus);
         this.current_poll = false;
         if ($.isFunction(this.adjustWait)) {
             this.current_wait = this.adjustWait(xhr, textStatus, this.current_wait);
         } else if (textStatus != 'success') {
             // increase the wait for server error, timeout, notmodified, or parser error.
             next_wait = this.current_wait * this.wait_multiplier;
             if (next_wait <= this.max_wait) {
                 this.current_wait = next_wait;
             } else {
                 this.current_wait = this.max_wait;
             }
             if ($.isFunction(this.userError)) {
                 this.userError(xhr, textStatus);
             }
         }
         if ($.isFunction(this.userComplete)) {
             this.userComplete(xhr, textStatus);
         }
     };

Regards,
Tony Cuny

Revision history for this message
Tony Cuny (tony-cuny) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.