1
jQuery (1.4.4)에서 CherryPy 서버 (3.1.2)로 DELETE HTTP 요청을 할 때 어떤 매개 변수도 전송되지 않습니다. POST, GET 및 PUT 요청은 매개 변수를 올바르게 전달합니다. 여기 jQuery에서 CherryPy로 DELETE 요청을 매개 변수를 보내지 않음
는 CherryPy 서버 코드입니다 :import cherrypy
class DeleteExample(object):
exposed = True
def PUT(self, *args, **kwargs):
print kwargs
def DELETE(self, *args, **kwargs):
print kwargs
global_conf = {'global': {'server.socket_port': 8080},
'/': {'request.dispatch': cherrypy.dispatch.MethodDispatcher(),
'tools.staticdir.root': '/home/kevin/workspace/delete_example',
'tools.staticdir.on': True,
'tools.staticdir.dir': 'src',
'tools.staticdir.index': 'index.html'}
}
cherrypy.quickstart(DeleteExample(), config=global_conf)
여기 jQuery 코드와 index.html을이다 :
{'second': '200', 'first': '10'}
127.0.0.1 - - [23/Jan/2011:04:02:48] "PUT/HTTP/1.1" 200 19 "http://localhost:8080/" "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.04 (lucid) Firefox/3.6.13"
{}
127.0.0.1 - - [23/Jan/2011:04:02:51] "DELETE/HTTP/1.1" 200 19 "http://localhost:8080/" "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.04 (lucid) Firefox/3.6.13"
:
<html>
<head>
<script type="text/javascript" src="jquery-1.4.4.js"></script>
<script>
$(document).ready(function() {
$.ajax({
type: "PUT",
url: "http://localhost:8080",
dataType: "json",
data: {first: 10, second: 200}
});
$.ajax({
type: "DELETE",
url: "http://localhost:8080",
dataType: "json",
data: {first: 10, second: 200}
});
});
</script>
</head>
<body>
</body>
</html>
이 CherryPy 웹 서버에서 인쇄되고 무슨이다 당신이 볼 수 있듯이 PUT과 DELETE 요청은 .ajax 함수를 사용하여 만든 것과 완전히 동일하다. 유형. 그러나 어떤 이유에서 PUT은 모든 매개 변수를 보내고 DELETE는 매개 변수를 보내지 않습니다.
누군가가 DELETE 요청이 적절한 매개 변수를 전송하지 않는 이유를 알고 있습니까?