10 examples of 'xmlhttprequest.responsetype' in JavaScript

Every line of 'xmlhttprequest.responsetype' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
87set responseType(responseType) {
88 if (this._sent) {
89 throw new Error(
90 'Failed to set the \'responseType\' property on \'XMLHttpRequest\': The ' +
91 'response type cannot be set after the request has been sent.'
92 );
93 }
94
95 this._responseType = responseType;
96}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

180set responseType(responseType: ResponseType): void {
181 if (this._sent) {
182 throw new Error(
183 "Failed to set the 'responseType' property on 'XMLHttpRequest': The " +
184 'response type cannot be set after the request has been sent.',
185 );
186 }
187 if (!SUPPORTED_RESPONSE_TYPES.hasOwnProperty(responseType)) {
188 warning(
189 false,
190 `The provided value '${responseType}' is not a valid 'responseType'.`,
191 );
192 return;
193 }
194
195 // redboxes early, e.g. for 'arraybuffer' on ios 7
196 invariant(
197 SUPPORTED_RESPONSE_TYPES[responseType] || responseType === 'document',
198 `The provided value '${responseType}' is unsupported in this environment.`,
199 );
200
201 if (responseType === 'blob') {
202 invariant(
203 BlobManager.isAvailable,
204 'Native module BlobModule is required for blob support',
205 );
206 }
207 this._responseType = responseType;
208}
97function xhrHasResponse(request) {
98 var type = request.responseType;
99 return type && type !== 'text' ?
100 request.response : // null on error
101 request.responseText; // '' on error
102}
1function get(url, responseType, fn) {
2 var xhr = new XMLHttpRequest();
3 xhr.open('GET', url, true);
4 xhr.setRequestHeader('Authorization', 'Basic ZmVlZHRlc3Q6YWJjMTIz');
5 xhr.responseType = responseType;
6 xhr.onload = function() {
7 fn(xhr.response);
8 };
9 xhr.send();
10}
142function getXMLHttpRequest() {
143 if (global.XMLHttpRequest) {
144 return new global.XMLHttpRequest;
145 } else {
146 try {
147 return new global.ActiveXObject('Microsoft.XMLHTTP');
148 } catch (e) {
149 throw new Error('XMLHttpRequest is not supported by your browser');
150 }
151 }
152}
116function xhr(self){
117 var req = win.XMLHttpRequest ? new XMLHttpRequest() : null
118 if(req === null) throw new Error("Browser (" + Browser.toString() +") cannot handle Requests")
119 self.request = req
120 return req
121}
242function responseTypeSetter() {
243 // will be only called to set "arraybuffer"
244 this.overrideMimeType('text/plain; charset=x-user-defined');
245}
7function getXHR() {
8 if (window.XMLHttpRequest
9 && ('file:' !== window.location.protocol || !window.ActiveXObject)) {
10 return new XMLHttpRequest();
11 } else {
12 try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {}
13 try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e1) {}
14 try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e2) {}
15 try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e3) {}
16 }
17 return false;
18}
66public set responseType(value:string) {
67 this._responseType = value;
68}
119export function createXHR() {
120 if (window.XMLHttpRequest) {
121 return new XMLHttpRequest();
122 }
123 return new window.ActiveXObject("Microsoft.XMLHTTP");
124}

Related snippets