By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,689 Members | 1,915 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,689 IT Pros & Developers. It's quick & easy.

xmlHTTPRequest problem

P: n/a
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?

thanks in advance.

Sep 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"David Wang" <da******@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
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!

Cross-domain access is restricted in JavaScript.
You *might* be able to step out of the sandbox by signing your script,
but I have never tested that myself. (I do it quite often with
signed Java Applets, thou...).

--
Dag.
Sep 12 '05 #2

P: n/a
"Dag Sunde" <me@dagsunde.com> wrote in message
news:jl*******************@juliett.dax.net...
"David Wang" <da******@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
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!

Cross-domain access is restricted in JavaScript.
You *might* be able to step out of the sandbox by signing your script,
but I have never tested that myself. (I do it quite often with
signed Java Applets, thou...).


Forgot...

You can make a proxy script on 'http://www.mysite.com/test.php', that
calls 'http://xml.mysite.com/test.php' on the server side and returns
the result.

--
Dag.
Sep 12 '05 #3

P: n/a


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/
Sep 12 '05 #4

P: n/a
it looks as if modifying document.domain DOES NOT work. i ended up
just leaving the script in another directory. =(

Sep 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.