XMLHttpRequest Level 2 æ代ã®ã¯ãã¹ãã¡ã¤ã³ãªã¯ã¨ã¹ã Proxy
XMLHttpRequest Level 2ã§ã¯、XMLHttpRequest ã Same Origin Policy ãæºãããªãã¦ãéä¿¡ã§ããããã«ããããã®ä»çµã¿ã追å ããã¦ãã¾ã。
ãã®ä»çµã¿ã¨ã¯、éä¿¡ç¸æã®ãµã¼ãã¼ã HTTP ã¬ã¹ãã³ã¹ãããä¸ã§ã¯ãã¹ãã¡ã¤ã³ã¢ã¯ã»ã¹ã許å¯ãããã¨ã示ã、Access-Control-Allow-Origin ã¨ããããããåºåããã¨ãããã®ã§ã。ãã®ãããã ãåºåããå ´å㯠GET ãªã¯ã¨ã¹ãã«ããã¯ãã¹ãã¡ã¤ã³ã¢ã¯ã»ã¹ã対象ã«ãªãã¾ã。
ãã®æ¡å¼µããã XMLHttpRequest ã®æ©è½ããã£ã¨æ´»ç¨ããããã«、Google App Engine ä¸ã§åã GET ã§åããç¯å²ã§ã¬ã¹ãã³ã¹ãããã« Access-Control-Allow-Origin: * (ãã¹ã¦è¨±å¯) ããã¨ãã¨ã追å ãã¦è¿ã Proxy ãéçºãã¦ã¿ã¾ãã。
使ãæ¹ã¯ http://allow-any-origin.appspot.com/http://www.google.co.jp/ ã®ããã«å¾ãã«ãã£ã¤ãã¦ãªã¯ã¨ã¹ãããã ãã§ã。
ãã¢
ãªã³ã¯
allow-any-origin.appspot.com
404 Blog Not Found:Ajax - Goodbye, JSONP. Hello, Access-Control-Allow-Origin
NetAgent Official Blog : IE8+jQueryã«ããã¯ãã¹ãã¡ã¤ã³éä¿¡ã¨XDomainRequestã©ããã¼ã®ä½æ - ãã® Proxy ããç´¹ä»ããã ãã¾ãã
ãã®ä»çµã¿ã¨ã¯、éä¿¡ç¸æã®ãµã¼ãã¼ã HTTP ã¬ã¹ãã³ã¹ãããä¸ã§ã¯ãã¹ãã¡ã¤ã³ã¢ã¯ã»ã¹ã許å¯ãããã¨ã示ã、Access-Control-Allow-Origin ã¨ããããããåºåããã¨ãããã®ã§ã。ãã®ãããã ãåºåããå ´å㯠GET ãªã¯ã¨ã¹ãã«ããã¯ãã¹ãã¡ã¤ã³ã¢ã¯ã»ã¹ã対象ã«ãªãã¾ã。
ãã®æ¡å¼µããã XMLHttpRequest ã®æ©è½ããã£ã¨æ´»ç¨ããããã«、Google App Engine ä¸ã§åã GET ã§åããç¯å²ã§ã¬ã¹ãã³ã¹ãããã« Access-Control-Allow-Origin: * (ãã¹ã¦è¨±å¯) ããã¨ãã¨ã追å ãã¦è¿ã Proxy ãéçºãã¦ã¿ã¾ãã。
使ãæ¹ã¯ http://allow-any-origin.appspot.com/http://www.google.co.jp/ ã®ããã«å¾ãã«ãã£ã¤ãã¦ãªã¯ã¨ã¹ãããã ãã§ã。
ãã¢
function xhrdemo() {
var url = document.getElementById("xhrdemo-url").value;
var req = window.XDomainRequest ? new XDomainRequest() : new XMLHttpRequest();
req.open("GET", "http://allow-any-origin.appspot.com/" + url, true);
req.onload = function (event) {
alert(req.responseText);
req = null;
}
req.send(null);
}
ãªã³ã¯
allow-any-origin.appspot.com
404 Blog Not Found:Ajax - Goodbye, JSONP. Hello, Access-Control-Allow-Origin
NetAgent Official Blog : IE8+jQueryã«ããã¯ãã¹ãã¡ã¤ã³éä¿¡ã¨XDomainRequestã©ããã¼ã®ä½æ - ãã® Proxy ããç´¹ä»ããã ãã¾ãã
ã³ã¡ã³ã
ã³ã¡ã³ããæ稿