CSSHttpRequest (CHR) is a method for cross-domain AJAX using CSS for transport.
Similar to JavaScript, this works because CSS is not subject to the same-origin policy that affects XMLHttpRequest. Like JSONP, CSSHttpRequest is limited to making GET requests. Unlike JSONP, untrusted third-party JavaScript cannot execute in the context of the calling page.
A request is invoked using the CSSHttpRequest.get(url, callback) function:
CSSHttpRequest.get(
"http://www.nb.io/hacks/csshttprequest/hello-world/",
function(response) { alert(response); }
);
Data is encoded on the server into URI-encoded 2KB chunks and serialized into CSS @import rules with a modified about: URI scheme. The response is decoded and returned to the callback function as a string:
@import url(about:chr:Hello%20World!);
CSSHttpRequest is open source under an Apache License (Version 2.0).
http://nb.io/hacks/csshttprequest/
Комментариев нет:
Отправить комментарий