OpenLayers OpenLayers

Changeset 5539

Show
Ignore:
Timestamp:
12/20/07 12:28:51 (1 year ago)
Author:
tschaub
Message:

Abort XMLHttpRequest on tile.destroy for WFS. The loadURL function now returns a request object. Thanks pgiraud for the fix. r=crschmidt (closes #964)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Ajax.js

    r5535 r5539  
    4646 * params - {String} Params on get (doesnt seem to work) 
    4747 * caller - {Object} object which gets callbacks 
    48  * onComplete - {Function} callback for success 
    49  * onFailure - {Function} callback for failure 
    50  * 
    51  * Both callbacks optional (though silly) 
     48 * onComplete - {Function} Optional callback for success.  The callback 
     49 *     will be called with this set to caller and will receive the request 
     50 *     object as an argument. 
     51 * onFailure - {Function} Optional callback for failure.  In the event of 
     52 *     a failure, the callback will be called with this set to caller and will 
     53 *     receive the request object as an argument. 
     54 * 
     55 * Returns: 
     56 * {OpenLayers.Ajax.Request}  The request object.  To abort loading, call 
     57 *     request.transport.abort(); 
    5258 */ 
    5359OpenLayers.loadURL = function(uri, params, caller, 
     
    6571 
    6672    // from prototype.js 
    67     new OpenLayers.Ajax.Request(uri,  
    68                      {   method: 'get',  
    69                          parameters: params, 
    70                          onComplete: success,  
    71                          onFailure: failure 
    72                       } 
    73                      ); 
     73    return new OpenLayers.Ajax.Request( 
     74        uri,  
     75        { 
     76            method: 'get',  
     77            parameters: params, 
     78            onComplete: success,  
     79            onFailure: failure 
     80        } 
     81    ); 
    7482}; 
    7583 
  • trunk/openlayers/lib/OpenLayers/Tile/WFS.js

    r4985 r5539  
    2929    url: null, 
    3030     
     31    /**  
     32     * Property: request  
     33     * {OpenLayers.Ajax.Request}  
     34     */  
     35    request: null,      
     36     
    3137    /** TBD 3.0 - reorder the parameters to the init function to put URL  
    3238     *             as last, so we can continue to call tile.initialize()  
     
    5864        this.features = null; 
    5965        this.url = null; 
     66        if(this.request) { 
     67            this.request.transport.abort(); 
     68        } 
    6069    }, 
    6170 
     
    98107    */ 
    99108    loadFeaturesForRegion:function(success, failure) { 
    100         OpenLayers.loadURL(this.url, null, this, success); 
     109        this.request = OpenLayers.loadURL(this.url, null, this, success); 
    101110    }, 
    102111     
  • trunk/openlayers/tests/Tile/test_WFS.html

    r4227 r5539  
    4343     
    4444    function test_99_Tile_WFS_destroy(t) { 
    45         t.plan( 6 ); 
     45        t.plan(8); 
    4646 
    4747        var layer = {}; // bogus layer 
     
    5757 
    5858  
     59        var _gAbort = false;  
     60        tile.request = {  
     61            transport: {  
     62                abort: function() {  
     63                    _gAbort = true;  
     64                }  
     65            }  
     66        }  
     67 
     68         
    5969        tile.destroy(); 
    6070 
     
    6373        t.ok(tile.size == null, "tile.size set to null"); 
    6474        t.ok(tile.position == null, "tile.position set to null"); 
     75        t.ok(_gAbort, "request transport is aborted"); 
    6576         
    6677        t.ok(tile.events == null, "tile.events set to null"); 
     78         
     79        tile.requestSuccess({'requestText': '<xml><foo /></xml>'}); 
     80        t.ok(true, "Didn't fail after calling requestSuccess on destroyed tile."); 
    6781    } 
    6882