最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to do a synchronous XMLHttpRequest in Chrome App? - Stack Overflow

programmeradmin2浏览0评论

Using the following code:

var xhr = new XMLHttpRequest();
xhr.open('GET', url, false);

Yields the following error:

Uncaught InvalidAccessError: Failed to execute 'open' on 'XMLHttpRequest': Synchronous requests are disabled for this page.

Is it simply not possible, or am I doing it wrong? Do I need extra permissions?

Using the following code:

var xhr = new XMLHttpRequest();
xhr.open('GET', url, false);

Yields the following error:

Uncaught InvalidAccessError: Failed to execute 'open' on 'XMLHttpRequest': Synchronous requests are disabled for this page.

Is it simply not possible, or am I doing it wrong? Do I need extra permissions?

Share Improve this question asked Dec 29, 2014 at 18:05 sollnisssollniss 2,0032 gold badges22 silver badges38 bronze badges 3
  • 2 Why would you ever want to do that ? – adeneo Commented Dec 29, 2014 at 18:07
  • 1 @adeneo could be useful within a web-worker, where there is no concern of blocking the UI thread – levi Commented Dec 29, 2014 at 18:16
  • PDFJS uses it in the viewer. – sollniss Commented Dec 29, 2014 at 18:23
Add a ment  | 

1 Answer 1

Reset to default 5

Synchronous XMLHttpRequests are disabled by default for Chrome apps.

Check this link to see all disabled web features and the workarounds. For this case:

Use async-only XMLHttpRequest: Getting Rid of Synchrounous XXRs.

发布评论

评论列表(0)

  1. 暂无评论