konraditurbe
konraditurbe

Reputation: 165

XMLHttpRequest does not work in a Chrome app

I am new to XMLHttpRequest and JavaScript and all this stuff.
I made a gopro WiFi app to control gopro cameras with XMLHttpRequest, but it does not work with the packaged Chrome app, it works with the HTML file in Chrome.
Source
Any ideas?

Upvotes: 1

Views: 144

Answers (2)

Xan
Xan

Reputation: 77513

Your problem is using inline scripting (e.g. <button onclick="command('bacpac','PW','%00')">)

This is disallowed by Chrome's Content Security Policy for apps/extensions, and you cannot override this.

You'll have to purge your index.html of all inline code and add handlers (or indeed, buttons) from a script. Example in the Chrome docs.

Upvotes: 1

Marijn
Marijn

Reputation: 276

It appears that you're not using XHR (XMLHttpRequest) (at least I can't find any usage of it in your code), instead you're trying to dynamically create tags with remote url's as src. Loading remote scripts in tags is not allowed in the apps CSP.

So the way to fix this, is to actually use XHR.

Upvotes: 0

Related Questions