{{draft}}{{APIRef('XMLHttpRequest')}}
The XMLHttpRequest.overrideMimeType() method overrides the MIME type returned by the server. This may be used, for example, to force a stream to be treated and parsed as text/xml, even if the server does not report it as such. This method must be called before send()
.
void overrideMimeType(DOMString mimetype);
Syntax
var newRequest = request.clone();
Parameters
None.
Return value
A {{domxref("Request")}} object, which is an exact copy of the Request
that clone()
was called on.
Example
In the following snippet, we create a new request using the {{domxref("Request.Request()")}}
constructor (for an image file in the same directory as the script), then clone the request.
var myRequest = new Request('flowers.jpg'); var newRequest = myRequest.clone(); // a copy of the request is now stored in newRequest
Specifications
Specification | Status | Comment |
---|---|---|
{{SpecName('XMLHttpRequest', '#the-overrideMimeType()-method', 'overrideMimeType()')}} | {{Spec2('XMLHttpRequest')}} | WHATWG living standard |
Browser compatibility
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | {{CompatChrome(1)}} | {{CompatUnknown}} | {{CompatIe('5')}}[1] {{CompatIe('7')}} |
{{CompatVersionUnknown}} | {{CompatSafari('1.2')}} |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | {{CompatUnknown}} | 1.0 | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
[1] This feature was implemented via ActiveXObject(). Internet Explorer implements the standard XMLHttpRequest since version 7.