简体   繁体   中英

How to make cors request with ajax and jquery only?

I am fetching some data from some other third-party website and I am doing this with iff jquery and ajax so, how can I make this happening? because it says origin is not allowed by Access-Control-Allow-Origin.

CORS isn't a feature of the request . You make the HTTP request with Ajax exactly the same way as you make any other HTTP request with Ajax.

The server you are making the request to has to grant permission to the website you are making the request from using CORS headers in the response (and possibly also to the preflight OPTIONS request in the case of a complex request).

You need to add Access-Control-Allow-Origin: http://example.com (where the example URL is the origin of the request) to the response headers from the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM