systemxhr: cross-domain xmlhttprequests

Post on 15-Jan-2015

335 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

How to use SystemXHR on Firefox OS

TRANSCRIPT

systemXHRcross domain XMLHttpRequests

XMLHttpRequestprovides an easy way to retrieve data from a URL without having to do a full page refresh

Yes, I meant

AJAX

Transporting messages inweb based

chat

showing

live data

behind almost every spinner

var request = new XMLHttpRequest();

request.onload = function() {console.log(this.responseText);

};

request.open("get", "yourFile.txt", true);

request.send();

my-own-server.com

other-dudes-server.com

This “feature” has a fancy name =

same origin security policy

You cannot access a different domain unless

CORSis enabled by the server administrator

firefox os fixes this by adding support for

systemXHR

var request = new XMLHttpRequest();

request.onload = function() {console.log(this.responseText);

};

request.open("get", "yourFile.txt", true);

request.send();

var request = new XMLHttpRequest({mozSystem: true

});

• Privileged App• systemXHR permission

Requirements

{ "name": "My App", "description": "My elevator pitch goes here", "launch_path": "/index.html", "icons": { "128": "/img/icon-128.png" }, "developer": { "name": "Your name or organization", "url": "http://your-homepage-here.org" }}

{ "name": "My App", "description": "My elevator pitch goes here", "launch_path": "/index.html", "icons": { "128": "/img/icon-128.png" }, "developer": { "name": "Your name or organization", "url": "http://your-homepage-here.org" },

}

"type": "privileged", "permissions": { "systemXHR": "for fetching data from..."

}

any-dudes-server.com

WARNINGUnauthorized use of copyrighted material

without permission of copyright holders is highly discouraged, and you might get sued

as well.

top related