我試圖在REST中完成web服務的html + javascript部分。有了這個代碼,例如:選項在XMLHTTPRequest中請求代替PUT
<!DOCTYPE html>
<html lang="en"
<script type="text/javascript">
function testPut(url){
var xhr = new XMLHttpRequest();
xhr.open('PUT', url, false);
xhr.setRequestHeader('Content-Type', 'text/plain');
xhr.send(null);
}
</script>
<body>
<form name="test" action="">
<input type="button" value="Lanceur" onclick="testPut('http://fake.es:8080')" />
</form>
</body>
</html>
但在Web服務器(使用web.py做)我得到選項,而不是PUT:
111.111.111.111:52014 - - [15/May/2013 17:01:47] "HTTP/1.1 OPTIONS /" - 200 OK
如何CON我解決呢?要刪除OPTIONS請求並僅發送PUT?
類似的問題(這裏)[http://stackoverflow.com/q/8153832/57091]。 – robsch