Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the cross domain issue [closed]

If I asked a stupid question here, Please don't laugh at me .

I have being heard Cross Domain Issue many times, But not really get involved in it in real case. So I searched it in the google. But found many posts are talking about The cross domain issue when make a ajax call. Not found even a post to tell about what exactly cross domain issue is, and why the cross domain is not allowed? and more question is if I say the cross domain issue, does it mean I made a wrong ajax request to different domain? Any other cases would cause this issue? Thanks.

The posts I read are

How do I send a cross-domain POST request via JavaScript?

"No 'Access-Control-Allow-Origin' header is present on the requested resource"

like image 258
Joe.wang Avatar asked Dec 05 '22 06:12

Joe.wang


2 Answers

This is a security restriction that prevents requests being made from one origin to another.

For example, it will prevent an https:// page hitting an http:// address because the protocol is different.

It will stop example.com calling another.com because it is a different domain.

It will stop www.example.com calling subdomain.example.com because it is a different sub domain.

And it will stop example.com:80 calling example.com:8080 because it is a different port.

It is possible to make cross-origin requests either using JSONP (if you trust the server!) or using a CORS request (Cross-Origin Resource Sharing), which both client and server must agree to (I can supply more details if you need it on this).

like image 82
Fenton Avatar answered Dec 09 '22 15:12

Fenton


1.what exactly cross domain issue is & not allowed : it is because same-site origin policy which blocks Web pages from accessing data from another domain. for information assurance, javascript is limited to send request from one to another.

2.A cross domain request is not a wrong one. you may deal with it by some methods,like jsonp.

this link is about jsonp: Jsonp


like image 20
MichealRay Avatar answered Dec 09 '22 15:12

MichealRay