Results 1 to 4 of 4

Thread: Ajax / Connection timeout

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Mar 2011
    Posts
    72

    Default Ajax / Connection timeout

    according to the docs one should be able to set a fail timeout...
    Code:
    Ext.Ajax.request({
                url: "someurl",
                timeout:500,
                failure:function() {
                    alert('fail');
                },
                success:function() {
                    alert('sucess');
                }
            });
    but it doesn't seem to work and throws an error...
    "Can't find variable request"
    it should call the failure method as well shouldn't it?

    i tried using just a Ext.data.Connection and didn't work either - same error
    valid bug?

  2. #2
    Touch Premium Member
    Join Date
    Jun 2010
    Posts
    324

    Default

    Bump. Anything?

  3. #3
    Touch Premium Member
    Join Date
    Apr 2007
    Posts
    139

    Default

    Heh... I came here to see whether what I was seeing was a known bug... and I find your report from weeks ago, uncommented. Here's what I've found: IMHO this is a simple typo causing the failure. Change/overwrite Ext.data.Connection.abort:

    Code:
    abort : function(r) {
            if (r && this.isLoading(r)) {
                if (!request.timedout) {
                    request.aborted = true;
                }
                
                r.xhr.abort();
            }
    ...to this:

    Code:
    abort : function(r) {
            if (r && this.isLoading(r)) {
                if (!r.timedout) {
                    r.aborted = true;
                }
                
                r.xhr.abort();
            }
    The parameter passed is called r only, but in the if statement the code is checking request. Above change fixed the issue for me.

    Michael
    HTC Desire - Android: 2.2 - Kernel: 2.6.32.15-gf5a401c - Build: 2.29.405.2 - WebKit: 3.1

  4. #4
    Touch Premium Member
    Join Date
    Apr 2007
    Posts
    139

    Default

    FWIW: I just updated to 1.1.1 (for subcribers only...), and this issue seems to be fixed in there. The new code looks like this:

    Code:
        abort : function(request) {
            if (request && this.isLoading(request)) {
                if (!request.timedout) {
                    request.aborted = true;
                }
                
                request.xhr.abort();
            }
            else if (!request) {
                var id;
                for(id in this.requests) {
                    if (!this.requests.hasOwnProperty(id)) {
                        continue;
                    }
                    this.abort(this.requests[id]);
                }
            }
        },
    Michael
    HTC Desire - Android: 2.2 - Kernel: 2.6.32.15-gf5a401c - Build: 2.29.405.2 - WebKit: 3.1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •