PDA

View Full Version : Ajax / Connection timeout



phil.fuse
27 Jul 2011, 1:23 PM
according to the docs one should be able to set a fail timeout...


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?

profunctional
1 Sep 2011, 8:21 AM
Bump. Anything?

mherger
6 Sep 2011, 4:47 AM
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:


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

r.xhr.abort();
}


...to this:


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

mherger
8 Sep 2011, 8:21 PM
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:


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