【发布时间】:2013-03-25 00:20:58
【问题描述】:
我得到了这个代码:
var req = new HttpRequest();
req.open("POST", "http://localhost:8031/rest/user/insert");
req.setRequestHeader("Content-type", "application/json");
req.send(json.stringify(user_map));
但是,当我在提琴手中看到它时,我没有发送 POST 动词,而是看到:
OPTIONS http://localhost:8031/rest/user/insert HTTP/1.1
Host: localhost:8031
Connection: keep-alive
Access-Control-Request-Method: POST
Origin: http://127.0.0.1:3030
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.33 (KHTML, like Gecko) Chrome/27.0.1430.0 (Dart) Safari/537.33
Access-Control-Request-Headers: origin, content-type
Accept: */*
Referer: http://127.0.0.1:3030/E:/grole/dart/Clases/Clases/web/out/clases.html
Accept-Encoding: gzip,deflate,sdch
Accept-Language: es-ES,es;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
如您所见,它使用的是 OPTIONS 动词而不是 POST?
发生了什么事?
【问题讨论】:
-
OPTION 动词用于发送预检请求,用于检查服务器是否发送跨域请求。因为源 -> 127.0.0.1:8031 和主机 -> localhos:3t
标签: post httprequest dart