1 | /* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for |
---|
2 | * full list of contributors). Published under the Clear BSD license. |
---|
3 | * See http://svn.openlayers.org/trunk/openlayers/license.txt for the |
---|
4 | * full text of the license. */ |
---|
5 | |
---|
6 | /** |
---|
7 | * @requires OpenLayers/Request/XMLHttpRequest.js |
---|
8 | * @requires OpenLayers/Console.js |
---|
9 | */ |
---|
10 | |
---|
11 | OpenLayers.ProxyHost = ""; |
---|
12 | //OpenLayers.ProxyHost = "examples/proxy.cgi?url="; |
---|
13 | |
---|
14 | /** |
---|
15 | * Ajax reader for OpenLayers |
---|
16 | * |
---|
17 | * @uri url to do remote XML http get |
---|
18 | * @param {String} 'get' format params (x=y&a=b...) |
---|
19 | * @who object to handle callbacks for this request |
---|
20 | * @complete the function to be called on success |
---|
21 | * @failure the function to be called on failure |
---|
22 | * |
---|
23 | * example usage from a caller: |
---|
24 | * |
---|
25 | * caps: function(request) { |
---|
26 | * -blah- |
---|
27 | * }, |
---|
28 | * |
---|
29 | * OpenLayers.loadURL(url,params,this,caps); |
---|
30 | * |
---|
31 | * Notice the above example does not provide an error handler; a default empty |
---|
32 | * handler is provided which merely logs the error if a failure handler is not |
---|
33 | * supplied |
---|
34 | * |
---|
35 | */ |
---|
36 | |
---|
37 | |
---|
38 | /** |
---|
39 | * Function: OpenLayers.nullHandler |
---|
40 | * @param {} request |
---|
41 | */ |
---|
42 | OpenLayers.nullHandler = function(request) { |
---|
43 | OpenLayers.Console.userError(OpenLayers.i18n("unhandledRequest", {'statusText':request.statusText})); |
---|
44 | }; |
---|
45 | |
---|
46 | /** |
---|
47 | * APIFunction: OpenLayers.loadURL |
---|
48 | * Background load a document. For more flexibility in using XMLHttpRequest, |
---|
49 | * see the <OpenLayers.Request> methods. |
---|
50 | * |
---|
51 | * Parameters: |
---|
52 | * uri - {String} URI of source doc |
---|
53 | * params - {String} or {Object} GET params. Either a string in the form |
---|
54 | * "?hello=world&foo=bar" (do not forget the leading question mark) |
---|
55 | * or an object in the form {'hello': 'world', 'foo': 'bar} |
---|
56 | * caller - {Object} object which gets callbacks |
---|
57 | * onComplete - {Function} Optional callback for success. The callback |
---|
58 | * will be called with this set to caller and will receive the request |
---|
59 | * object as an argument. Note that if you do not specify an onComplete |
---|
60 | * function, <OpenLayers.nullHandler> will be called (which pops up a |
---|
61 | * user friendly error message dialog). |
---|
62 | * onFailure - {Function} Optional callback for failure. In the event of |
---|
63 | * a failure, the callback will be called with this set to caller and will |
---|
64 | * receive the request object as an argument. Note that if you do not |
---|
65 | * specify an onComplete function, <OpenLayers.nullHandler> will be called |
---|
66 | * (which pops up a user friendly error message dialog). |
---|
67 | * |
---|
68 | * Returns: |
---|
69 | * {<OpenLayers.Request.XMLHttpRequest>} The request object. To abort loading, |
---|
70 | * call request.abort(). |
---|
71 | */ |
---|
72 | OpenLayers.loadURL = function(uri, params, caller, |
---|
73 | onComplete, onFailure) { |
---|
74 | |
---|
75 | if(typeof params == 'string') { |
---|
76 | params = OpenLayers.Util.getParameters(params); |
---|
77 | } |
---|
78 | var success = (onComplete) ? onComplete : OpenLayers.nullHandler; |
---|
79 | var failure = (onFailure) ? onFailure : OpenLayers.nullHandler; |
---|
80 | |
---|
81 | return OpenLayers.Request.GET({ |
---|
82 | url: uri, params: params, |
---|
83 | success: success, failure: failure, scope: caller |
---|
84 | }); |
---|
85 | }; |
---|
86 | |
---|
87 | /** |
---|
88 | * Function: OpenLayers.parseXMLString |
---|
89 | * Parse XML into a doc structure |
---|
90 | * |
---|
91 | * Parameters: |
---|
92 | * text - {String} |
---|
93 | * |
---|
94 | * Returns: |
---|
95 | * {?} Parsed AJAX Responsev |
---|
96 | */ |
---|
97 | OpenLayers.parseXMLString = function(text) { |
---|
98 | |
---|
99 | //MS sucks, if the server is bad it dies |
---|
100 | var index = text.indexOf('<'); |
---|
101 | if (index > 0) { |
---|
102 | text = text.substring(index); |
---|
103 | } |
---|
104 | |
---|
105 | var ajaxResponse = OpenLayers.Util.Try( |
---|
106 | function() { |
---|
107 | var xmldom = new ActiveXObject('Microsoft.XMLDOM'); |
---|
108 | xmldom.loadXML(text); |
---|
109 | return xmldom; |
---|
110 | }, |
---|
111 | function() { |
---|
112 | return new DOMParser().parseFromString(text, 'text/xml'); |
---|
113 | }, |
---|
114 | function() { |
---|
115 | var req = new XMLHttpRequest(); |
---|
116 | req.open("GET", "data:" + "text/xml" + |
---|
117 | ";charset=utf-8," + encodeURIComponent(text), false); |
---|
118 | if (req.overrideMimeType) { |
---|
119 | req.overrideMimeType("text/xml"); |
---|
120 | } |
---|
121 | req.send(null); |
---|
122 | return req.responseXML; |
---|
123 | } |
---|
124 | ); |
---|
125 | |
---|
126 | return ajaxResponse; |
---|
127 | }; |
---|
128 | |
---|
129 | |
---|
130 | /** |
---|
131 | * Namespace: OpenLayers.Ajax |
---|
132 | */ |
---|
133 | OpenLayers.Ajax = { |
---|
134 | |
---|
135 | /** |
---|
136 | * Method: emptyFunction |
---|
137 | */ |
---|
138 | emptyFunction: function () {}, |
---|
139 | |
---|
140 | /** |
---|
141 | * Method: getTransport |
---|
142 | * |
---|
143 | * Returns: |
---|
144 | * {Object} Transport mechanism for whichever browser we're in, or false if |
---|
145 | * none available. |
---|
146 | */ |
---|
147 | getTransport: function() { |
---|
148 | return OpenLayers.Util.Try( |
---|
149 | function() {return new XMLHttpRequest();}, |
---|
150 | function() {return new ActiveXObject('Msxml2.XMLHTTP');}, |
---|
151 | function() {return new ActiveXObject('Microsoft.XMLHTTP');} |
---|
152 | ) || false; |
---|
153 | }, |
---|
154 | |
---|
155 | /** |
---|
156 | * Property: activeRequestCount |
---|
157 | * {Integer} |
---|
158 | */ |
---|
159 | activeRequestCount: 0 |
---|
160 | }; |
---|
161 | |
---|
162 | /** |
---|
163 | * Namespace: OpenLayers.Ajax.Responders |
---|
164 | * {Object} |
---|
165 | */ |
---|
166 | OpenLayers.Ajax.Responders = { |
---|
167 | |
---|
168 | /** |
---|
169 | * Property: responders |
---|
170 | * {Array} |
---|
171 | */ |
---|
172 | responders: [], |
---|
173 | |
---|
174 | /** |
---|
175 | * Method: register |
---|
176 | * |
---|
177 | * Parameters: |
---|
178 | * responderToAdd - {?} |
---|
179 | */ |
---|
180 | register: function(responderToAdd) { |
---|
181 | for (var i = 0; i < this.responders.length; i++){ |
---|
182 | if (responderToAdd == this.responders[i]){ |
---|
183 | return; |
---|
184 | } |
---|
185 | } |
---|
186 | this.responders.push(responderToAdd); |
---|
187 | }, |
---|
188 | |
---|
189 | /** |
---|
190 | * Method: unregister |
---|
191 | * |
---|
192 | * Parameters: |
---|
193 | * responderToRemove - {?} |
---|
194 | */ |
---|
195 | unregister: function(responderToRemove) { |
---|
196 | OpenLayers.Util.removeItem(this.reponders, responderToRemove); |
---|
197 | }, |
---|
198 | |
---|
199 | /** |
---|
200 | * Method: dispatch |
---|
201 | * |
---|
202 | * Parameters: |
---|
203 | * callback - {?} |
---|
204 | * request - {?} |
---|
205 | * transport - {?} |
---|
206 | */ |
---|
207 | dispatch: function(callback, request, transport) { |
---|
208 | var responder; |
---|
209 | for (var i = 0; i < this.responders.length; i++) { |
---|
210 | responder = this.responders[i]; |
---|
211 | |
---|
212 | if (responder[callback] && |
---|
213 | typeof responder[callback] == 'function') { |
---|
214 | try { |
---|
215 | responder[callback].apply(responder, |
---|
216 | [request, transport]); |
---|
217 | } catch (e) {} |
---|
218 | } |
---|
219 | } |
---|
220 | } |
---|
221 | }; |
---|
222 | |
---|
223 | OpenLayers.Ajax.Responders.register({ |
---|
224 | /** |
---|
225 | * Function: onCreate |
---|
226 | */ |
---|
227 | onCreate: function() { |
---|
228 | OpenLayers.Ajax.activeRequestCount++; |
---|
229 | }, |
---|
230 | |
---|
231 | /** |
---|
232 | * Function: onComplete |
---|
233 | */ |
---|
234 | onComplete: function() { |
---|
235 | OpenLayers.Ajax.activeRequestCount--; |
---|
236 | } |
---|
237 | }); |
---|
238 | |
---|
239 | /** |
---|
240 | * Class: OpenLayers.Ajax.Base |
---|
241 | */ |
---|
242 | OpenLayers.Ajax.Base = OpenLayers.Class({ |
---|
243 | |
---|
244 | /** |
---|
245 | * Constructor: OpenLayers.Ajax.Base |
---|
246 | * |
---|
247 | * Parameters: |
---|
248 | * options - {Object} |
---|
249 | */ |
---|
250 | initialize: function(options) { |
---|
251 | this.options = { |
---|
252 | method: 'post', |
---|
253 | asynchronous: true, |
---|
254 | contentType: 'application/xml', |
---|
255 | parameters: '' |
---|
256 | }; |
---|
257 | OpenLayers.Util.extend(this.options, options || {}); |
---|
258 | |
---|
259 | this.options.method = this.options.method.toLowerCase(); |
---|
260 | |
---|
261 | if (typeof this.options.parameters == 'string') { |
---|
262 | this.options.parameters = |
---|
263 | OpenLayers.Util.getParameters(this.options.parameters); |
---|
264 | } |
---|
265 | } |
---|
266 | }); |
---|
267 | |
---|
268 | /** |
---|
269 | * Class: OpenLayers.Ajax.Request |
---|
270 | * *Deprecated*. Use <OpenLayers.Request> method instead. |
---|
271 | * |
---|
272 | * Inherit: |
---|
273 | * - <OpenLayers.Ajax.Base> |
---|
274 | */ |
---|
275 | OpenLayers.Ajax.Request = OpenLayers.Class(OpenLayers.Ajax.Base, { |
---|
276 | |
---|
277 | /** |
---|
278 | * Property: _complete |
---|
279 | * |
---|
280 | * {Boolean} |
---|
281 | */ |
---|
282 | _complete: false, |
---|
283 | |
---|
284 | /** |
---|
285 | * Constructor: OpenLayers.Ajax.Request |
---|
286 | * |
---|
287 | * Parameters: |
---|
288 | * url - {String} |
---|
289 | * options - {Object} |
---|
290 | */ |
---|
291 | initialize: function(url, options) { |
---|
292 | OpenLayers.Ajax.Base.prototype.initialize.apply(this, [options]); |
---|
293 | |
---|
294 | if (OpenLayers.ProxyHost && OpenLayers.String.startsWith(url, "http")) { |
---|
295 | url = OpenLayers.ProxyHost + encodeURIComponent(url); |
---|
296 | } |
---|
297 | |
---|
298 | this.transport = OpenLayers.Ajax.getTransport(); |
---|
299 | this.request(url); |
---|
300 | }, |
---|
301 | |
---|
302 | /** |
---|
303 | * Method: request |
---|
304 | * |
---|
305 | * Parameters: |
---|
306 | * url - {String} |
---|
307 | */ |
---|
308 | request: function(url) { |
---|
309 | this.url = url; |
---|
310 | this.method = this.options.method; |
---|
311 | var params = OpenLayers.Util.extend({}, this.options.parameters); |
---|
312 | |
---|
313 | if (this.method != 'get' && this.method != 'post') { |
---|
314 | // simulate other verbs over post |
---|
315 | params['_method'] = this.method; |
---|
316 | this.method = 'post'; |
---|
317 | } |
---|
318 | |
---|
319 | this.parameters = params; |
---|
320 | |
---|
321 | if (params = OpenLayers.Util.getParameterString(params)) { |
---|
322 | // when GET, append parameters to URL |
---|
323 | if (this.method == 'get') { |
---|
324 | this.url += ((this.url.indexOf('?') > -1) ? '&' : '?') + params; |
---|
325 | } else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) { |
---|
326 | params += '&_='; |
---|
327 | } |
---|
328 | } |
---|
329 | try { |
---|
330 | var response = new OpenLayers.Ajax.Response(this); |
---|
331 | if (this.options.onCreate) { |
---|
332 | this.options.onCreate(response); |
---|
333 | } |
---|
334 | |
---|
335 | OpenLayers.Ajax.Responders.dispatch('onCreate', |
---|
336 | this, |
---|
337 | response); |
---|
338 | |
---|
339 | this.transport.open(this.method.toUpperCase(), |
---|
340 | this.url, |
---|
341 | this.options.asynchronous); |
---|
342 | |
---|
343 | if (this.options.asynchronous) { |
---|
344 | window.setTimeout( |
---|
345 | OpenLayers.Function.bind(this.respondToReadyState, this, 1), |
---|
346 | 10); |
---|
347 | } |
---|
348 | |
---|
349 | this.transport.onreadystatechange = |
---|
350 | OpenLayers.Function.bind(this.onStateChange, this); |
---|
351 | this.setRequestHeaders(); |
---|
352 | |
---|
353 | this.body = this.method == 'post' ? |
---|
354 | (this.options.postBody || params) : null; |
---|
355 | this.transport.send(this.body); |
---|
356 | |
---|
357 | // Force Firefox to handle ready state 4 for synchronous requests |
---|
358 | if (!this.options.asynchronous && |
---|
359 | this.transport.overrideMimeType) { |
---|
360 | this.onStateChange(); |
---|
361 | } |
---|
362 | } catch (e) { |
---|
363 | this.dispatchException(e); |
---|
364 | } |
---|
365 | }, |
---|
366 | |
---|
367 | /** |
---|
368 | * Method: onStateChange |
---|
369 | */ |
---|
370 | onStateChange: function() { |
---|
371 | var readyState = this.transport.readyState; |
---|
372 | if (readyState > 1 && !((readyState == 4) && this._complete)) { |
---|
373 | this.respondToReadyState(this.transport.readyState); |
---|
374 | } |
---|
375 | }, |
---|
376 | |
---|
377 | /** |
---|
378 | * Method: setRequestHeaders |
---|
379 | */ |
---|
380 | setRequestHeaders: function() { |
---|
381 | var headers = { |
---|
382 | 'X-Requested-With': 'XMLHttpRequest', |
---|
383 | 'Accept': 'text/javascript, text/html, application/xml, text/xml, */*', |
---|
384 | 'OpenLayers': true |
---|
385 | }; |
---|
386 | |
---|
387 | if (this.method == 'post') { |
---|
388 | headers['Content-type'] = this.options.contentType + |
---|
389 | (this.options.encoding ? '; charset=' + this.options.encoding : ''); |
---|
390 | |
---|
391 | /* Force "Connection: close" for older Mozilla browsers to work |
---|
392 | * around a bug where XMLHttpRequest sends an incorrect |
---|
393 | * Content-length header. See Mozilla Bugzilla #246651. |
---|
394 | */ |
---|
395 | if (this.transport.overrideMimeType && |
---|
396 | (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005) { |
---|
397 | headers['Connection'] = 'close'; |
---|
398 | } |
---|
399 | } |
---|
400 | // user-defined headers |
---|
401 | if (typeof this.options.requestHeaders == 'object') { |
---|
402 | var extras = this.options.requestHeaders; |
---|
403 | |
---|
404 | if (typeof extras.push == 'function') { |
---|
405 | for (var i = 0, length = extras.length; i < length; i += 2) { |
---|
406 | headers[extras[i]] = extras[i+1]; |
---|
407 | } |
---|
408 | } else { |
---|
409 | for (var i in extras) { |
---|
410 | headers[i] = extras[i]; |
---|
411 | } |
---|
412 | } |
---|
413 | } |
---|
414 | |
---|
415 | for (var name in headers) { |
---|
416 | this.transport.setRequestHeader(name, headers[name]); |
---|
417 | } |
---|
418 | }, |
---|
419 | |
---|
420 | /** |
---|
421 | * Method: success |
---|
422 | * |
---|
423 | * Returns: |
---|
424 | * {Boolean} - |
---|
425 | */ |
---|
426 | success: function() { |
---|
427 | var status = this.getStatus(); |
---|
428 | return !status || (status >=200 && status < 300); |
---|
429 | }, |
---|
430 | |
---|
431 | /** |
---|
432 | * Method: getStatus |
---|
433 | * |
---|
434 | * Returns: |
---|
435 | * {Integer} - Status |
---|
436 | */ |
---|
437 | getStatus: function() { |
---|
438 | try { |
---|
439 | return this.transport.status || 0; |
---|
440 | } catch (e) { |
---|
441 | return 0; |
---|
442 | } |
---|
443 | }, |
---|
444 | |
---|
445 | /** |
---|
446 | * Method: respondToReadyState |
---|
447 | * |
---|
448 | * Parameters: |
---|
449 | * readyState - {?} |
---|
450 | */ |
---|
451 | respondToReadyState: function(readyState) { |
---|
452 | var state = OpenLayers.Ajax.Request.Events[readyState]; |
---|
453 | var response = new OpenLayers.Ajax.Response(this); |
---|
454 | |
---|
455 | if (state == 'Complete') { |
---|
456 | try { |
---|
457 | this._complete = true; |
---|
458 | (this.options['on' + response.status] || |
---|
459 | this.options['on' + (this.success() ? 'Success' : 'Failure')] || |
---|
460 | OpenLayers.Ajax.emptyFunction)(response); |
---|
461 | } catch (e) { |
---|
462 | this.dispatchException(e); |
---|
463 | } |
---|
464 | |
---|
465 | var contentType = response.getHeader('Content-type'); |
---|
466 | } |
---|
467 | |
---|
468 | try { |
---|
469 | (this.options['on' + state] || |
---|
470 | OpenLayers.Ajax.emptyFunction)(response); |
---|
471 | OpenLayers.Ajax.Responders.dispatch('on' + state, |
---|
472 | this, |
---|
473 | response); |
---|
474 | } catch (e) { |
---|
475 | this.dispatchException(e); |
---|
476 | } |
---|
477 | |
---|
478 | if (state == 'Complete') { |
---|
479 | // avoid memory leak in MSIE: clean up |
---|
480 | this.transport.onreadystatechange = OpenLayers.Ajax.emptyFunction; |
---|
481 | } |
---|
482 | }, |
---|
483 | |
---|
484 | /** |
---|
485 | * Method: getHeader |
---|
486 | * |
---|
487 | * Parameters: |
---|
488 | * name - {String} Header name |
---|
489 | * |
---|
490 | * Returns: |
---|
491 | * {?} - response header for the given name |
---|
492 | */ |
---|
493 | getHeader: function(name) { |
---|
494 | try { |
---|
495 | return this.transport.getResponseHeader(name); |
---|
496 | } catch (e) { |
---|
497 | return null; |
---|
498 | } |
---|
499 | }, |
---|
500 | |
---|
501 | /** |
---|
502 | * Method: dispatchException |
---|
503 | * If the optional onException function is set, execute it |
---|
504 | * and then dispatch the call to any other listener registered |
---|
505 | * for onException. |
---|
506 | * |
---|
507 | * If no optional onException function is set, we suspect that |
---|
508 | * the user may have also not used |
---|
509 | * OpenLayers.Ajax.Responders.register to register a listener |
---|
510 | * for the onException call. To make sure that something |
---|
511 | * gets done with this exception, only dispatch the call if there |
---|
512 | * are listeners. |
---|
513 | * |
---|
514 | * If you explicitly want to swallow exceptions, set |
---|
515 | * request.options.onException to an empty function (function(){}) |
---|
516 | * or register an empty function with <OpenLayers.Ajax.Responders> |
---|
517 | * for onException. |
---|
518 | * |
---|
519 | * Parameters: |
---|
520 | * exception - {?} |
---|
521 | */ |
---|
522 | dispatchException: function(exception) { |
---|
523 | var handler = this.options.onException; |
---|
524 | if(handler) { |
---|
525 | // call options.onException and alert any other listeners |
---|
526 | handler(this, exception); |
---|
527 | OpenLayers.Ajax.Responders.dispatch('onException', this, exception); |
---|
528 | } else { |
---|
529 | // check if there are any other listeners |
---|
530 | var listener = false; |
---|
531 | var responders = OpenLayers.Ajax.Responders.responders; |
---|
532 | for (var i = 0; i < responders.length; i++) { |
---|
533 | if(responders[i].onException) { |
---|
534 | listener = true; |
---|
535 | break; |
---|
536 | } |
---|
537 | } |
---|
538 | if(listener) { |
---|
539 | // call all listeners |
---|
540 | OpenLayers.Ajax.Responders.dispatch('onException', this, exception); |
---|
541 | } else { |
---|
542 | // let the exception through |
---|
543 | throw exception; |
---|
544 | } |
---|
545 | } |
---|
546 | } |
---|
547 | }); |
---|
548 | |
---|
549 | /** |
---|
550 | * Property: Events |
---|
551 | * {Array(String)} |
---|
552 | */ |
---|
553 | OpenLayers.Ajax.Request.Events = |
---|
554 | ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; |
---|
555 | |
---|
556 | /** |
---|
557 | * Class: OpenLayers.Ajax.Response |
---|
558 | */ |
---|
559 | OpenLayers.Ajax.Response = OpenLayers.Class({ |
---|
560 | |
---|
561 | /** |
---|
562 | * Property: status |
---|
563 | * |
---|
564 | * {Integer} |
---|
565 | */ |
---|
566 | status: 0, |
---|
567 | |
---|
568 | |
---|
569 | /** |
---|
570 | * Property: statusText |
---|
571 | * |
---|
572 | * {String} |
---|
573 | */ |
---|
574 | statusText: '', |
---|
575 | |
---|
576 | /** |
---|
577 | * Constructor: OpenLayers.Ajax.Response |
---|
578 | * |
---|
579 | * Parameters: |
---|
580 | * request - {Object} |
---|
581 | */ |
---|
582 | initialize: function(request) { |
---|
583 | this.request = request; |
---|
584 | var transport = this.transport = request.transport, |
---|
585 | readyState = this.readyState = transport.readyState; |
---|
586 | |
---|
587 | if ((readyState > 2 && |
---|
588 | !(!!(window.attachEvent && !window.opera))) || |
---|
589 | readyState == 4) { |
---|
590 | this.status = this.getStatus(); |
---|
591 | this.statusText = this.getStatusText(); |
---|
592 | this.responseText = transport.responseText == null ? |
---|
593 | '' : String(transport.responseText); |
---|
594 | } |
---|
595 | |
---|
596 | if(readyState == 4) { |
---|
597 | var xml = transport.responseXML; |
---|
598 | this.responseXML = xml === undefined ? null : xml; |
---|
599 | } |
---|
600 | }, |
---|
601 | |
---|
602 | /** |
---|
603 | * Method: getStatus |
---|
604 | */ |
---|
605 | getStatus: OpenLayers.Ajax.Request.prototype.getStatus, |
---|
606 | |
---|
607 | /** |
---|
608 | * Method: getStatustext |
---|
609 | * |
---|
610 | * Returns: |
---|
611 | * {String} - statusText |
---|
612 | */ |
---|
613 | getStatusText: function() { |
---|
614 | try { |
---|
615 | return this.transport.statusText || ''; |
---|
616 | } catch (e) { |
---|
617 | return ''; |
---|
618 | } |
---|
619 | }, |
---|
620 | |
---|
621 | /** |
---|
622 | * Method: getHeader |
---|
623 | */ |
---|
624 | getHeader: OpenLayers.Ajax.Request.prototype.getHeader, |
---|
625 | |
---|
626 | /** |
---|
627 | * Method: getResponseHeader |
---|
628 | * |
---|
629 | * Returns: |
---|
630 | * {?} - response header for given name |
---|
631 | */ |
---|
632 | getResponseHeader: function(name) { |
---|
633 | return this.transport.getResponseHeader(name); |
---|
634 | } |
---|
635 | }); |
---|
636 | |
---|
637 | |
---|
638 | /** |
---|
639 | * Function: getElementsByTagNameNS |
---|
640 | * |
---|
641 | * Parameters: |
---|
642 | * parentnode - {?} |
---|
643 | * nsuri - {?} |
---|
644 | * nsprefix - {?} |
---|
645 | * tagname - {?} |
---|
646 | * |
---|
647 | * Returns: |
---|
648 | * {?} |
---|
649 | */ |
---|
650 | OpenLayers.Ajax.getElementsByTagNameNS = function(parentnode, nsuri, |
---|
651 | nsprefix, tagname) { |
---|
652 | var elem = null; |
---|
653 | if (parentnode.getElementsByTagNameNS) { |
---|
654 | elem = parentnode.getElementsByTagNameNS(nsuri, tagname); |
---|
655 | } else { |
---|
656 | elem = parentnode.getElementsByTagName(nsprefix + ':' + tagname); |
---|
657 | } |
---|
658 | return elem; |
---|
659 | }; |
---|
660 | |
---|
661 | |
---|
662 | /** |
---|
663 | * Function: serializeXMLToString |
---|
664 | * Wrapper function around XMLSerializer, which doesn't exist/work in |
---|
665 | * IE/Safari. We need to come up with a way to serialize in those browser: |
---|
666 | * for now, these browsers will just fail. #535, #536 |
---|
667 | * |
---|
668 | * Parameters: |
---|
669 | * xmldom {XMLNode} xml dom to serialize |
---|
670 | * |
---|
671 | * Returns: |
---|
672 | * {?} |
---|
673 | */ |
---|
674 | OpenLayers.Ajax.serializeXMLToString = function(xmldom) { |
---|
675 | var serializer = new XMLSerializer(); |
---|
676 | var data = serializer.serializeToString(xmldom); |
---|
677 | return data; |
---|
678 | }; |
---|