Andy
Andy

Reputation: 11

JavaScript & XMLHttpRequest

I know that due to JavaScript security sandbox, it is not possible to load xml data from outside of the domain which the JavaScript code is on.

But if I am using the localhost:8080 and the xml document is coming from the localhost in the same machine but from another port like 8081, is this considered as same domain or not?

Thanks

andy e and ken and jacob, thank you all :-)

Upvotes: 1

Views: 293

Answers (1)

Andy E
Andy E

Reputation: 344753

Different port is considered "different origin", and thus violates the same origin policy.

URL                                                Outcome   Reason
=================================================================================
http://store.company.com/dir2/other.html           Success   
http://store.company.com/dir/inner/another.html    Success   
https://store.company.com/secure.html              Failure   Different protocol
http://store.company.com:81/dir/etc.html           Failure   Different port
http://news.company.com/dir/other.html             Failure   Different host

Source(s): Same origin policy for JavaScript - MDC, Same origin policy - Wikipedia.

Upvotes: 5

Related Questions