Adding cross-browser XMLHttpRequest functionality and convenience methods around it in the OpenLayers.Request namespace. Deprecating OpenLayers.Ajax.Request. Full support sync/async requests using all HTTP verbs now. r=elemoine (closes #1565)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@7335 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
+26
-26
@@ -30,16 +30,18 @@ OpenLayers.ProxyHost = "";
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @param {} request
|
||||
*/
|
||||
/**
|
||||
* Function: OpenLayers.nullHandler
|
||||
* @param {} request
|
||||
*/
|
||||
OpenLayers.nullHandler = function(request) {
|
||||
alert(OpenLayers.i18n("unhandledRequest", {'statusText':request.statusText}));
|
||||
};
|
||||
|
||||
/**
|
||||
* Function: loadURL
|
||||
* Background load a document.
|
||||
* Background load a document. For more flexibility in using XMLHttpRequest,
|
||||
* see the <OpenLayers.Request> methods.
|
||||
*
|
||||
* Parameters:
|
||||
* uri - {String} URI of source doc
|
||||
@@ -49,35 +51,32 @@ OpenLayers.nullHandler = function(request) {
|
||||
* caller - {Object} object which gets callbacks
|
||||
* onComplete - {Function} Optional callback for success. The callback
|
||||
* will be called with this set to caller and will receive the request
|
||||
* object as an argument.
|
||||
* object as an argument. Note that if you do not specify an onComplete
|
||||
* function, <OpenLayers.nullHandler> will be called (which pops up an
|
||||
* alert dialog).
|
||||
* onFailure - {Function} Optional callback for failure. In the event of
|
||||
* a failure, the callback will be called with this set to caller and will
|
||||
* receive the request object as an argument.
|
||||
* receive the request object as an argument. Note that if you do not
|
||||
* specify an onComplete function, <OpenLayers.nullHandler> will be called
|
||||
* (which pops up an alert dialog).
|
||||
*
|
||||
* Returns:
|
||||
* {XMLHttpRequest} The request object. To abort loading, call
|
||||
* request.abort().
|
||||
* {<OpenLayers.Request.XMLHttpRequest>} The request object. To abort loading,
|
||||
* call request.abort().
|
||||
*/
|
||||
OpenLayers.loadURL = function(uri, params, caller,
|
||||
onComplete, onFailure) {
|
||||
|
||||
var success = (onComplete) ? OpenLayers.Function.bind(onComplete, caller)
|
||||
: OpenLayers.nullHandler;
|
||||
|
||||
var failure = (onFailure) ? OpenLayers.Function.bind(onFailure, caller)
|
||||
: OpenLayers.nullHandler;
|
||||
|
||||
// from prototype.js
|
||||
var request = new OpenLayers.Ajax.Request(
|
||||
uri,
|
||||
{
|
||||
method: 'get',
|
||||
parameters: params,
|
||||
onComplete: success,
|
||||
onFailure: failure
|
||||
}
|
||||
);
|
||||
return request.transport;
|
||||
|
||||
if(typeof params == 'string') {
|
||||
params = OpenLayers.Util.getParameters(params);
|
||||
}
|
||||
var success = (onComplete) ? onComplete : OpenLayers.nullHandler;
|
||||
var failure = (onFailure) ? onFailure : OpenLayers.nullHandler;
|
||||
|
||||
return OpenLayers.Request.GET({
|
||||
url: uri, params: params,
|
||||
success: success, failure: failure, scope: caller
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -263,6 +262,7 @@ OpenLayers.Ajax.Base = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Ajax.Request
|
||||
* *Deprecated*. Use <OpenLayers.Request> method instead.
|
||||
*
|
||||
* Inherit:
|
||||
* - <OpenLayers.Ajax.Base>
|
||||
|
||||
Reference in New Issue
Block a user