我在前面使用 Backbone 和 jQuery,并且有一个使用 Python/Tornado 的 API。因为我的 API 位于http://api.domain.com而站点位于http://domain.com,所以当我尝试保存 Backbone 模型时,它首先执行 OPTIONS 请求。问题是即使服务器返回了有效响应,它也会显示“加载已取消”。
请求标头:
OPTIONS /user/xdfr456890sd HTTP/1.1
Host: api.domain.com
Connection: keep-alive
Access-Control-Request-Method: PUT
Origin: http://domain.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_1) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4
Access-Control-Request-Headers: origin, content-type, accept
Accept: */*
Referer: http://domain.com/settings
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
响应标头:
HTTP/1.1 200 OK
Date: Thu, 06 Dec 2012 05:41:51 GMT
Content-Type: text/plain
Content-Length: 0
Connection: keep-alive
Server: TornadoServer/2.4
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://domain.com
Access-Control-Allow-Methods: PUT, DELETE, POST, GET
Access-Control-Allow-Headers: Origin, Accept-Language, Accept-Encoding, Accept-Charset, Access-Control-Request-Headers, X-Scheme, Connection, Accept, User-Agent, Access-Control-Request-Method, Host, Referer, X-Real-Ip
我错过了什么吗?做错了什么?我已经尝试了响应标头及其值的所有可能组合。Access-Control-Allow-Origin
是Origin
请求标头是什么。