Static web page http request problem

Yes, just did a test, static html page, using jQuery to initiate an ajax request, request the background project running under the local Tomcat to get json data.

1. Visit directly through the web page:

option
2.webstorm:

got the data
I would like to ask whether the static web page can issue a http request to get the json data from the background? If not, why not? If I can, why do I only issue option requests when I do the test? Does issuing an option request without subsequent action mean that the http request failed? I have looked up a lot of information on the Internet, but there is a big difference. I beg your pardon.

Feb.28,2021

static pages when people allow you to ajax, this is obviously js cross-domain, because of security issues, tomcat does not allow cross-domain by default. Option request is to see whether the server supports cross-domain. If cross-domain is not allowed, the browser will not send ajax request to the backend server. If you want to allow cross-domain, the server should add a http header: Access-Control-Allow-Origin


1. Static web page using ajax is able to issue http requests, get json data
2. You only send an options request because it is cross-domain. The browser will first send an options pre-request to see if the backend supports cross-domain access. The back-end interface needs to handle the options request. Learn about cors

across domains.
Menu