New Xmlhttprequest().responsetype Empty
Why is responseType empty? JavaScript var xhr = new XMLHttpRequest(); xhr.open(method,url,true); xhr.onreadystatechange = function() { if (xhr.readyState=='4') { if (xhr.status
Solution 1:
As clarified in the comments the new XMLHttpRequest().responseType
is intended as a request header and does not represent the media type/mime response from the server (which would have made logical sense). So to test for response types use something along the following lines:
Full Media Type/Mime
console.log(xhr.getResponseHeader('content-type'));//application/json
Specific Media Type/Mime
console.log(xhr.getResponseHeader('content-type').split('/')[1]);//json
Post a Comment for "New Xmlhttprequest().responsetype Empty"