您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

奇怪的JQuery错误“代码501,消息不支持的方法选项”

奇怪的JQuery错误“代码501,消息不支持的方法选项”

要做的是编写自定义的 。我在MyHandler中添加方法,以告诉浏览器我的服务器支持CORS。这是通过发送标头 。另外,我在 方法添加了“ self.send_header(’Access-Control-Allow-Origin’,’*’)”语句。

class MyHandler(BaseHTTPRequestHandler):
    def do_OPTIONS(self):           
        self.send_response(200, "ok")       
        self.send_header('Access-Control-Allow-Origin', '*')                
        self.send_header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
        self.send_header("Access-Control-Allow-Headers", "X-Requested-With")

    def do_GET(self):           
        self.send_response(200)
        self.send_header('Access-Control-Allow-Origin', '*')
        self.send_header('Content-type',    'text/html')                                    
        self.end_headers()              
        self.wfile.write("<html><body>Hello World!</body></html>")
        self.connection.shutdown(1)
JS 2022/1/1 18:45:03 有330人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶