How to do a synchronous XMLHttpRequest in Chrome App?

浪子不回头ぞ 提交于 2019-12-11 11:36:20

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/27693814/how-to-do-a-synchronous-xmlhttprequest-in-chrome-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!