The loadURL function now returns something that acts more like XMLHttpRequest should. If you name this return request, call request.abort to abort the request. r=crschmidt (closes #1386)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@6408 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2008-02-29 00:16:47 +00:00
parent 145981c303
commit 836f037fda
4 changed files with 12 additions and 16 deletions

View File

@@ -53,8 +53,8 @@ OpenLayers.nullHandler = function(request) {
* receive the request object as an argument.
*
* Returns:
* {OpenLayers.Ajax.Request} The request object. To abort loading, call
* request.transport.abort();
* {XMLHttpRequest} The request object. To abort loading, call
* request.abort().
*/
OpenLayers.loadURL = function(uri, params, caller,
onComplete, onFailure) {
@@ -66,7 +66,7 @@ OpenLayers.loadURL = function(uri, params, caller,
: OpenLayers.nullHandler;
// from prototype.js
return new OpenLayers.Ajax.Request(
var request = new OpenLayers.Ajax.Request(
uri,
{
method: 'get',
@@ -75,6 +75,7 @@ OpenLayers.loadURL = function(uri, params, caller,
onFailure: failure
}
);
return request.transport;
};
/**

View File

@@ -66,7 +66,7 @@ OpenLayers.Tile.WFS = OpenLayers.Class(OpenLayers.Tile, {
this.features = null;
this.url = null;
if(this.request) {
this.request.transport.abort();
this.request.abort();
//this.request.destroy();
this.request = null;
}
@@ -111,8 +111,7 @@ OpenLayers.Tile.WFS = OpenLayers.Class(OpenLayers.Tile, {
*/
loadFeaturesForRegion:function(success, failure) {
if(this.request) {
this.request.transport.abort();
//this.request.destroy();
this.request.abort();
}
this.request = OpenLayers.loadURL(this.url, null, this, success);
},

View File

@@ -72,10 +72,8 @@
//running request (cancelled) -- 4 tests + 1 test (for request abort)
tile.request = {
transport: {
'abort': function() {
t.ok(true, "request aborted");
}
'abort': function() {
t.ok(true, "request aborted");
}
};
OpenLayers.Tile.WFS.prototype.loadFeaturesForRegion.apply(tile, [g_Success]);
@@ -100,10 +98,8 @@
var _gAbort = false;
tile.request = {
transport: {
abort: function() {
_gAbort = true;
}
abort: function() {
_gAbort = true;
}
}

View File

@@ -1,6 +1,6 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Draw Feature Acceptance Test</title>
<title>Ajax Acceptance Test</title>
<style type="text/css">
body {
@@ -64,7 +64,7 @@
<ul>
<li>synchronous: "request completed" then "other processing"</li>
<li>asynchronous: "other processing" then "request completed"</li>
<li>abort: "request aborted" then "other processing"</li>
<li>abort: "request aborted" then "other processing" (note that real XHR behavior would not call onComplete with abort - meaning "request aborted" would not be displayed here)</li>
</ul>
</body>
</html>