確實允許CORS,因爲當我試圖GET-ING它,我返回狀態200
和頭部有Access-Control-Allow-Origin:* *
使用螢火蟲:
請求:
xhr=new XMLHttpRequest();
xhr.open('get','https://graph.facebook.com/id',true);
xhr.send();
個標頭:
Response Headers
Access-Control-Allow-Origin *
Cache-Control private, no-cache, no-store, must-revalidate
Connection keep-alive
Content-Length 181
Content-Type text/javascript; charset=UTF-8
Date Tue, 19 Jun 2012 22:41:46 GMT
Etag "some random string"
Expires Sat, 01 Jan 2000 00:00:00 GMT
Pragma no-cache
X-FB-Debug some random string
X-FB-Rev some random number
Request Headers
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Encoding gzip, deflate
Accept-Language en-us,en;q=0.5
Connection keep-alive
DNT 1
Host graph.facebook.com
Origin http://localhost:8080
Referer http://localhost:8080/login
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
非常感謝!這個作品完美! – user1165862
是的,它在tampermonkey(從問題的例子)中工作,正如我所說,這是讓我困惑的! – user1165862
另外一個'快速'問題:我如何在函數外部使用變量內容?我試圖定義它bellow var my_id,但它不起作用。 – user1165862