Home > Mobile >  What triggers cross-domain violation when AJAX request?
What triggers cross-domain violation when AJAX request?

Time:01-14

I was asked a question below and cannot find the answer. I looked up similar posts, but many posts (like this) ended up talking about cross-origin, not cross-domain. What is the answer to the below question?

Q: Assume you are working on a webpage at http://example.com/path/to/foo.html. if you were to send an AJAX request to the following URLs, which one would NOT trigger a cross-domain violation?

  1. http://example.com/bar
  2. https://example.com/path/to/bar.html
  3. https://example.com:80/bar
  4. http://www.example.com/bar
  5. C and D

Thank you in advance.

CodePudding user response:

Due to this:

A resource is cross-origin when it's located at a different (sub)domain, protocol, or port!

You should not get CORS in option 1 and 4

Take a look at this article fully describe CORS.

  •  Tags:  
  • Related