This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

overrideMimeType

Summary

Overrides the MIME type returned by the server.

Method of apis/xhr/XMLHttpRequestapis/xhr/XMLHttpRequest

Syntax

 .overrideMimeType();

Return Value

No return value

Examples

function handler() {
  if (xhr.readyState === 4 /* complete */) {
    if (xhr.status === 200) {
            console.log(xhr.responseText);
        }
    }
}

var xhr = new XMLHttpRequest();
xhr.overrideMimeType("text/xml");
xhr.open("GET", "http://localhost/test.xml", true);
xhr.onreadystatechange = handler;
xhr.send();

Notes

This method may be used (for example) to force a returned stream to be treated and parsed as text/xml, even if the server does not report it as such. If used, this method must be called before send().

Related specifications

W3C XMLHttpRequest Specification
W3C Working Draft

Attributions