Skip to content

Instantly share code, notes, and snippets.

@hozumi
Created March 2, 2013 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hozumi/5070846 to your computer and use it in GitHub Desktop.
Save hozumi/5070846 to your computer and use it in GitHub Desktop.
var xhr = new XMLHttpRequest();
// undefined
xhr.open('POST', 'http://localhost:4000/', true);
// undefined
xhr.onreadystatechange = function (a){console.log(a);}
// function (a){console.log(a);}
xhr.send('{"a":"b"}');
// undefined
// XMLHttpRequest cannot load http://localhost:4000/. Origin http://d.hatena.ne.jp is not allowed by Access-Control-Allow-Origin```

リクエストのヘッダー

Request URL:http://localhost:4000/
Request Method:OPTIONS
Status Code:200 OK

Request Header
Accept:*/*
Accept-Charset:Shift_JIS,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:ja,en-US;q=0.8,en;q=0.6
Access-Control-Request-Headers:origin, content-type
Access-Control-Request-Method:POST
Connection:keep-alive
Host:localhost:4000
Origin:http://d.hatena.ne.jp
Referer:http://d.hatena.ne.jp/hasegawayosuke/comment?date=20130302&section=p1
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.99 Safari/537.22

Response Header
Allow:GET,HEAD,OPTIONS
Connection:Keep-Alive
Content-Length:0
Date:Sat, 02 Mar 2013 12:39:06 GMT
Server:WEBrick/1.3.1 (Ruby/1.9.3/2012-11-10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment