reqwest icon indicating copy to clipboard operation
reqwest copied to clipboard

Uncaught TypeError: Cannot call method 'abort' of undefined on line 218

Open troynt opened this issue 14 years ago • 4 comments

line 218 Uncaught TypeError: Cannot call method 'abort' of undefined

The requests are going through as expected, but I get that error message.

I'll probably just add a typeof check there, but I wanted to bring it to your attention.

My AJAX request looks like the following:

var xhr = reqwest({
    url: url,
    data: options,
    dataType: 'jsonp',
    type: 'jsonp',
    timeout: this.opts.timeout,
    crossDomain: true,
    success: function(resp) {
      callback.success(resp);
    },
    error: function(resp) {
      if (error_timeout) {
        clearTimeout(error_timeout);
      }
      callback.error(resp);
    }
  });

Thanks,

Troy

troynt avatar Feb 08 '12 18:02 troynt

The following gets rid of the error:

Reqwest.prototype = {
  abort: function () {
    if( typeof this.request !== 'undefined' && typeof this.request.abort === 'function' ) {
      this.request.abort();
    }
  }
...

troynt avatar Feb 08 '12 18:02 troynt

hmm... could be that you have that combo of jsonp and crossDomain both set. remove the crossDomain and see if it still throws the error

ded avatar Feb 08 '12 18:02 ded

but yeah, you're right on that... jsonp requests aren't XHR objects, which of course don't have abort methods... so yeah we'll have to fix that

ded avatar Feb 08 '12 18:02 ded

@ded issue is an old one and running into this on IE8,9.

shellscape avatar Mar 18 '15 16:03 shellscape