views:

47

answers:

2

Hello, 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 :-)

+5  A: 

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.

Andy E
A: 

Typically the same origin policy you describe does consider a different port to be a different domain. The policy is enforced by each browser, so some may vary (the Wikipedia article says the TCP port is considered in the policy "in most browsers").

JacobM
thanx jacob :-)
Andy