20
我得到這個代碼:爲什麼HttpRequest發送OPTIONS動詞而不是POST?
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
正如你所看到的,它使用的是選項動詞而不是POST?
發生了什麼事?
OPTION謂詞用於發送預檢請求來檢查服務器是否發送跨域請求。由於原點 - > 127.0.0.1:8031和主機 - > localhos:3t – kiran 2014-05-24 15:40:51