Strange JQuery Error “code 501, message Unsupported method OPTIONS”

前端 未结 4 1145
Happy的楠姐
Happy的楠姐 2020-12-10 14:29

I am learning the JQuery Get method. I start up a Python HTTP server:

(just typing command \"Python -m SimpleHTTPServer\").

It\'s fine to t

4条回答
  •  眼角桃花
    2020-12-10 14:33

    Looks like a CORS preflight request (https://developer.mozilla.org/En/HTTP_access_control)

    I guess you are trying to access to a different domain/port. Depending on the request, the browser will send a preflight request (an OPTION request) to know if the server accepts the set of Headers or HTTP method you wanted to send in the first place. If the server responds OK, the browser will send the real request.

    Looks like that Python server doesn't implement OPTIONs requests, hence the error.

    Tip: Network inspection tools (tcpdump, wireshark, ngrep...) help a lot when dealing with http requests and/or network errors.

提交回复
热议问题