1
var xhr = new XMLHttpRequest();

xhr.responseType = 'json';

xhr.open('GET', '/api/album/category', false);

//ERROR: VM829:1 Uncaught DOMException: Failed to execute 'open' on 'XMLHttpRequest': Synchronous requests from a document must not set a response type.at :1:5(anonymous function) @ VM829:1

why xhr cannot set response type when async is false?????

SunkSky
  • 85
  • 7

1 Answers1

0

You cannot set the response type when the synchronous flag is set (i.e, asynch is false) . It will throw an "InvalidAccessError" exception . Refer https://xhr.spec.whatwg.org/#the-responsetype-attribute