| Index: tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate
|
| diff --git a/tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate b/tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate
|
| index 4a6a45e7a355224ef2cea973f7c6158de45dd945..aa47fc8ec4f0666b3a4be5ae36e38a0f7ee89447 100644
|
| --- a/tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate
|
| +++ b/tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate
|
| @@ -221,5 +221,44 @@ $else
|
| $endif
|
| }
|
|
|
| + /**
|
| + * Makes a cross-origin request to the specified URL.
|
| + *
|
| + * This API provides a subset of [request] which works on IE9. If IE9
|
| + * cross-origin support is not required then [request] should be used instead.
|
| + */
|
| + @Experimental()
|
| + static Future<String> requestCrossOrigin(String url,
|
| + {String method, String sendData}) {
|
| + if (supportsCrossOrigin) {
|
| + return request(url, method: method, sendData: sendData).then((xhr) {
|
| + return xhr.responseText;
|
| + });
|
| + }
|
| +$if DART2JS
|
| + var completer = new Completer<String>();
|
| + if (method == null) {
|
| + method = 'GET';
|
| + }
|
| + var xhr = JS('var', 'new XDomainRequest()');
|
| + JS('', '#.open(#, #)', xhr, method, url);
|
| + JS('', '#.onload = #', xhr, convertDartClosureToJS((e) {
|
| + var response = JS('String', '#.responseText', xhr);
|
| + completer.complete(response);
|
| + }, 1));
|
| + JS('', '#.onerror = #', xhr, convertDartClosureToJS((e) {
|
| + completer.completeError(e);
|
| + }, 1));
|
| +
|
| + if (sendData != null) {
|
| + JS('', '#.send(#)', xhr, sendData);
|
| + } else {
|
| + JS('', '#.send()', xhr);
|
| + }
|
| +
|
| + return completer.future;
|
| +$endif
|
| + }
|
| +
|
| $!MEMBERS
|
| }
|
|
|