David Wang wrote:
Ive been playing around with xmlHTTPRequest and was wondering if i was
programming a part of my code wrong.
what i want to do is have the browser access another part of my site
using xmlhttprequest.
however, when i use xmlhttp.open("POST",
'http://xml.mysite.com/test.php')
it fails, but if i use xmlhttp.open("POST",
'http://www.mysite.com/test.php') it works. Is access to another url
restricted in xmlhttp?
Yes, general with client-side scripting there are restrictions falling
under the "same origin policy" although that term has had a meaning
before XMLHttpRequest existed.
As for your particular problem in theory it could help to set
document.domain = 'mysite.com';
before you try your request as in your special case you do not want to
access a completely different domain but a subdomain.
I say in theory as that approach with setting document.domain was
introduced for cross frame scripting and I am not sure whether it
applies to XMLHttpRequest implementations as well.
You could try with your domain/sub-domains and report back whether that
improves things.
--
Martin Honnen
http://JavaScript.FAQTs.com/